[prev in list] [next in list] [prev in thread] [next in thread]
List: xerces-j-dev
Subject: Re: Runtime ClassCastException on class org.apache.xerces.dom.ElementNSImpl
From: robertlazarski <robertlazarski () gmail ! com>
Date: 2023-09-27 20:45:32
Message-ID: CABpPLBU6XhXN445GGm1rZ342Zf-oB+H9Sc0VuXEM_txSUcLrGQ () mail ! gmail ! com
[Download RAW message or body]
Thanks for the reply. For the record I confirmed this error happens on
xercesImpl-2.12.2.jar.
While I too am somewhat amazed this cast ever worked, it did actually work
for 10 years starting on this Rampart commit below.
"
commit b73690eefaad9027bb9633a20e29a218a1021cc9 (HEAD -> master)
Author: Amila Jayasekara <amilaj@apache.org>
Date: Thu Mar 8 08:11:32 2012 +0000
Refactored SAML2TokenIssuer and cleaned up code. Created a test
framework to write unit tests for trust scenarios. Fixed documentation
errors. Reduced code duplication. Added more tests.
"
I see that OMNode at runtime ends up being an Axiom class
DOOMNSAwareElementImpl
that "extends CoreElementImpl" , which implements "org.w3c.dom.Element" -
that to me explains why it compiles.
So, this is a runtime issue on code that worked fine for a long time.
Before I figure out how to rewrite the code in question as I'm not really
sure, I thought I'd ask why this happened all of sudden on the Xerces side
as I have no clue on the Axiom side.
On Wed, Sep 27, 2023 at 9:03 AM Rick Brown <tamrick@swbell.net> wrote:
> Ill throe this in, but i might be out in left field (or iut in da weeds)
> But this is a difference between axiom and DOM
> When working with JAXB and axis2 we had to be very specific as to which
> "space" we were in
> Axiom or DOM
>
> you cant just cast between them
>
> Rick Brown
>
> On Wednesday, September 27, 2023 at 01:30:53 PM CDT, robertlazarski <
> robertlazarski@gmail.com> wrote:
>
>
> 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.
>
[Attachment #3 (text/html)]
<div dir="ltr"><div><span style="font-family:monospace"><span \
style="color:rgb(0,0,0);background-color:rgb(255,255,255)">Thanks for the reply. For \
the record I confirmed this error happens on xercesImpl-2.12.2.jar. \
<br></span></span></div><div><span style="font-family:monospace"><span \
style="color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></span></span></div><div><span \
style="font-family:monospace"><span \
style="color:rgb(0,0,0);background-color:rgb(255,255,255)">While I too am somewhat \
amazed this cast ever worked, it did actually work for 10 years starting on this \
Rampart commit below.</span></span></div><div><span \
style="font-family:monospace"><span \
style="color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></span></span></div><div><span \
style="font-family:monospace"><span \
style="color:rgb(0,0,0);background-color:rgb(255,255,255)">"<br></span></span></div><div><div><span \
style="font-family:monospace"><span \
style="color:rgb(178,104,24);background-color:rgb(255,255,255)">commit \
b73690eefaad9027bb9633a20e29a218a1021cc9 (</span><span \
style="font-weight:bold;color:rgb(84,255,255);background-color:rgb(255,255,255)">HEAD \
-> </span><span style="font-weight:bold;color:rgb(84,255,84);background-color:rgb(255,255,255)">master</span><span \
style="color:rgb(178,104,24);background-color:rgb(255,255,255)">)</span><span \
style="color:rgb(0,0,0);background-color:rgb(255,255,255)"> </span><br>Author: Amila \
Jayasekara <<a href="mailto:amilaj@apache.org" \
target="_blank">amilaj@apache.org</a>> <br>Date: Thu Mar 8 08:11:32 2012 +0000
<br>
<br> Refactored SAML2TokenIssuer and cleaned up code. Created a test framework \
to write unit tests for trust scenarios. Fixed documentation errors. Reduced code \
duplication. Added more tests.</span></div><div><span \
style="font-family:monospace">"</span></div><div><span \
style="font-family:monospace"><br></span></div></div><div><span \
style="font-family:monospace"><span \
style="color:rgb(0,0,0);background-color:rgb(255,255,255)">I see that OMNode at \
runtime ends up being an Axiom class </span></span><span \
style="font-family:monospace"><span \
style="color:rgb(0,0,0);background-color:rgb(255,255,255)">DOOMNSAwareElementImpl \
that "</span><span \
style="color:rgb(135,255,175);background-color:rgb(255,255,255)">extends</span><span \
style="color:rgb(0,0,0);background-color:rgb(255,255,255)"> CoreElementImpl" , \
which implements "</span></span><span style="font-family:monospace"><span \
style="color:rgb(0,0,0);background-color:rgb(255,255,255)">org.w3c.dom.Element" \
- that to me explains why it compiles. </span><br></span><br></div><div><span \
style="font-family:monospace"><span \
style="color:rgb(0,0,0);background-color:rgb(255,255,255)">So, this is a runtime \
issue on code that worked fine for a long time. </span></span></div><div><span \
style="font-family:monospace"><span \
style="color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></span></span></div><div><span \
style="font-family:monospace"><span \
style="color:rgb(0,0,0);background-color:rgb(255,255,255)">Before I figure out how to \
rewrite the code in question as I'm not really sure, I thought I'd ask why \
this happened all of sudden on the Xerces side as I have no clue on the Axiom side. \
</span></span></div><br><div><span \
style="font-family:monospace"></span></div></div><br><div class="gmail_quote"><div \
dir="ltr" class="gmail_attr">On Wed, Sep 27, 2023 at 9:03 AM Rick Brown <<a \
href="mailto:tamrick@swbell.net" target="_blank">tamrick@swbell.net</a>> \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div \
style="font-family:Helvetica \
Neue,Helvetica,Arial,sans-serif;font-size:16px"><div></div> <div>Ill throe this in, \
but i might be out in left field (or iut in da weeds)</div><div>But this is a \
difference between axiom and DOM</div><div>When working with JAXB and axis2 we had to \
be very specific as to which "space" we were in</div><div>Axiom or \
DOM</div><div><br></div><div>you cant just cast between \
them</div><div><br></div><div>Rick Brown</div><div><br></div>
<div id="m_-5365263205531194603m_3558140001034825098ydp81f5c5e9yahoo_quoted_6628126962">
<div style="font-family:"Helvetica \
Neue",Helvetica,Arial,sans-serif;font-size:13px;color:rgb(38,40,42)">
<div>
On Wednesday, September 27, 2023 at 01:30:53 PM CDT, \
robertlazarski <<a href="mailto:robertlazarski@gmail.com" \
target="_blank">robertlazarski@gmail.com</a>> wrote: </div>
<div><br></div>
<div><br></div>
<div><div \
id="m_-5365263205531194603m_3558140001034825098ydp81f5c5e9yiv8636611883"><div \
dir="ltr"><div>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. <br></div><div><br></div><div>My \
environment is JDK 17 on Linux with a compiler target of JDK 11. </div><div> \
<br></div><div>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. </div><div><br></div><div>However, there is now a \
ClassCastException running a unit test when casting as shown. \
</div><div><br></div><div><span style="font-family:monospace"><span \
style="color:rgb(95,215,255);background-color:rgb(255,255,255)">import</span><span \
style="color:rgb(0,0,0);background-color:rgb(255,255,255)"> \
org.apache.axiom.om.OMElement;</span></span></div><div><div><span \
style="font-family:monospace"><span \
style="color:rgb(0,0,0);background-color:rgb(255,255,255)"></span></span></div><div><span \
style="font-family:monospace"><span \
style="color:rgb(95,215,255);background-color:rgb(255,255,255)">import</span><span \
style="color:rgb(0,0,0);background-color:rgb(255,255,255)"> \
org.apache.axiom.om.OMNode;</span><br></span></div></div><div><span \
style="font-family:monospace"><span \
style="color:rgb(95,215,255);background-color:rgb(255,255,255)">import</span><span \
style="color:rgb(0,0,0);background-color:rgb(255,255,255)"> \
org.w3c.dom.Element;</span></span></div><div><span \
style="font-family:monospace"><span \
style="color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></span></span></div><div>// \
<font color="#000000">defined as \
<wst:RequestedSecurityT</font>oken></div><div><span \
style="font-family:monospace"><span \
style="color:rgb(0,0,0);background-color:rgb(255,255,255)">OMElement \
requestedSecurityTokenElement = </span>...</span></div><div>// OpenSAML assertion \
defined as <saml> <font color="#000000">with org.w3c.dom.Element</font> \
</div><div><span style="font-family:monospace"><span \
style="color:rgb(0,0,0);background-color:rgb(255,255,255)">Element assertionElement = \
assertion.getDOM();</span><br></span></div><div>// Boom! <br></div><div><span \
style="font-family:monospace"><span \
style="color:rgb(0,0,0);background-color:rgb(255,255,255)">requestedSecurityTokenElement.addChild((OMNode)assertionElement);</span><br></span></div><div><span \
style="font-family:monospace"><br></span></div><div><span \
style="font-family:monospace">Error: <br></span></div><div><p><font \
color="#000000">java.lang.ClassCast</font><font color="#000000">Exce</font><font \
color="#000000">ption: class org.apache.xerces.dom.ElementNSImpl can</font>not 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') <br>
at org.apache.rahas.impl.SAML2TokenIssuer.createRequestSecurityTokenResponse(SAML2TokenIssuer.java:242)</p>
<p>The code is here. </p>
<p><a href="https://github.com/apache/axis-axis2-java-rampart/blob/master/modules/rampart-trust/src/main/java/org/apache/rahas/impl/SAML2TokenIssuer.java#L242" \
rel="nofollow" target="_blank">https://github.com/apache/axis-axis2-java-rampart/blob/ \
master/modules/rampart-trust/src/main/java/org/apache/rahas/impl/SAML2TokenIssuer.java#L242</a> \
<br></p><p>I tried asking the most prolific Axiom developer for help in the issue \
below a few weeks ago but got no response. <br></p><p><a \
href="https://issues.apache.org/jira/browse/RAMPART-449" rel="nofollow" \
target="_blank">https://issues.apache.org/jira/browse/RAMPART-449</a></p><p>I am \
asking here because I am stuck and need some type of guidance. <br></p></div></div> \
</div></div> </div>
</div></div></div></blockquote></div>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic