简体   繁体   中英

JBoss EAP 7 => ClassCastException: org.apache.jcp.xml.dsig.internal.dom.DOMReference cannot be cast to org.jcp.xml.dsig.internal.dom.DOMReference

I am getting this error:

java.lang.ClassCastException: org.apache.jcp.xml.dsig.internal.dom.DOMReference cannot be cast to org.jcp.xml.dsig.internal.dom.DOMReference

Maybe the problem is on the jboss-deployment-structure.xml of the servlet:

 <?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
  <deployment>
    <dependencies>
      <module name="javax.api"/>
      <module name="org.apache.santuario.xmlsec"/>
      <module name="org.apache.xerces" />
      <system export="true">
        <paths> 
          <path name="com/sun/org/apache/xerces/internal/dom"/>
        </paths>
      </system>
    </dependencies>
  </deployment>
</jboss-deployment-structure>

Do you have any hint of whats going on?

Thanks in advance.

Your problem is different xmlsec library version. org.apache.jcp.xml.dsig.internal.dom.DOMReference located in xmlsec-1.5.1.jar (org.apache.santuario.xmlsec module in JBoss) org.jcp.xml.dsig.internal.dom.DOMReference located in xmlsec-1.4.3.jar (dependency in your pom.xml)

Jboss 7 uses isolated modules https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7 it is complicated and i really don't know how it works inside.

But if simplify, when jboss start, it loads xmlsec-1.5.1, when start your application, it loads xmlsec-1.4.3. As result you have class cast exception, when pass DOMReference object between jboss and webapp classloders.

You can resolve your issue in different ways:

  • remove dependency of org.apache.santuario.xmlsec module in jboss-deployment-structure.xml. Application will use his own defined xmlsec-1.4.3 library
  • locate dependency xmlsec in pom.xml, set version to 1.5.1, and set scope to provided . Application will use JBoss module with xmlsec-1.5.1
  • locate dependency xmlsec in pom.xml and exclude it completly, if your code complies without xmlsec dependency. Application will use JBoss module with xmlsec-1.5.1

mvn:dependency:tree command helps here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM