I'm the VP of the Apache Axis project and on the PMC of the Apache Axiom
project, and I am trying to upgrade the Axis sub project Apache Rampart
project - last released in 2017 - to modern dependencies.
My environment is JDK 17 on Linux with a compiler target of JDK 11.
I mention all this because I have a Rampart unit test that I am trying to
fix. The code compiles fine, git history shows this code has no recent
changes in the area and just always worked.
However, there is now a ClassCastException running a unit test when casting
as shown.
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMNode;
import org.w3c.dom.Element;
// defined as <wst:RequestedSecurityToken>
OMElement requestedSecurityTokenElement = ...
// OpenSAML assertion defined as <saml> with org.w3c.dom.Element
Element assertionElement = assertion.getDOM();
// Boom!
requestedSecurityTokenElement.addChild((OMNode)assertionElement);
Error:
java.lang.ClassCastException: class org.apache.xerces.dom.ElementNSImpl cannot
be cast to class org.apache.axiom.om.OMNode
(org.apache.xerces.dom.ElementNSImpl and org.apache.axiom.om.OMNode are in
unnamed module of loader 'app')
at
org.apache.rahas.impl.SAML2TokenIssuer.createRequestSecurityTokenResponse(SAML2TokenIssuer.java:242)
The code is here.
https://github.com/apache/axis-axis2-java-rampart/blob/master/modules/rampart-trust/src/main/java/org/apache/rahas/impl/SAML2TokenIssuer.java#L242
I tried asking the most prolific Axiom developer for help in the issue
below a few weeks ago but got no response.
https://issues.apache.org/jira/browse/RAMPART-449
I am asking here because I am stuck and need some type of guidance.