Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-16443

[GSS](7.2.z) HHH-13285 - ClassCastException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory after dom4j update

    XMLWordPrintable

Details

    • Hide

      Remove dom4j.jar from the application or depend on the JBoss org.dom4j module which will ignore what is packaged in the app:

      <?xml version="1.0"?>
      <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
        <deployment>
          <dependencies>
             <module name="org.dom4j" export="true"/>
          </dependencies>
        </deployment>
      </jboss-deployment-structure>
      

      If the app requires the dom4.jar version that is packaged, then there is not a workaround currently

      Show
      Remove dom4j.jar from the application or depend on the JBoss org.dom4j module which will ignore what is packaged in the app: <?xml version= "1.0" ?> <jboss-deployment-structure xmlns= "urn:jboss:deployment-structure:1.2" > <deployment> <dependencies> <module name= "org.dom4j" export= " true " /> </dependencies> </deployment> </jboss-deployment-structure> If the app requires the dom4.jar version that is packaged, then there is not a workaround currently
    • Hide

      Deploy helloWorld.ear in EAP 7.1 CP6

      Show
      Deploy helloWorld.ear in EAP 7.1 CP6

    Description

      An application packaging dom4j.jar in the application was deploying without issue in EAP 7.1 CP5, in CP6 after dom4j update from 1.x to 2.x it now throws a class cast.

      It looks like org.hibernate.internal.util.xml.XMLHelper has some code to flip the TCCL, but I am not sure which classloader it is passing in, we should be having JPA/HIbernate in JBoss flip the TCCL to be the classloader of the EAP JPA/Hibernate class so that it uses the dom4j in JBoss and does not try to load one from the application.

      11:26:41,546 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 19) MSC000001: Failed to start service jboss.persistenceunit."helloWorld.ear/helloWorld-jpa.jar#helloWorld-jpa.jar": org.jboss.msc.service.StartException in service jboss.persistenceunit."helloWorld.ear/helloWorld-jpa.jar#helloWorld-jpa.jar": java.lang.ClassCastException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
      	at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:195)
      	at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:125)
      	at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:640)
      	at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:209)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      	at org.jboss.threads.JBossThread.run(JBossThread.java:320)
      Caused by: java.lang.ClassCastException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
      	at org.dom4j.DocumentFactory.getInstance(DocumentFactory.java:92)
      	at org.hibernate.internal.util.xml.XMLHelper$1.doWork(XMLHelper.java:33)
      	at org.hibernate.internal.util.xml.XMLHelper$1.doWork(XMLHelper.java:27)
      	at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.workWithClassLoader(ClassLoaderServiceImpl.java:358)
      	at org.hibernate.internal.util.xml.XMLHelper.<init>(XMLHelper.java:26)
      	at org.hibernate.envers.boot.internal.EnversServiceImpl.initialize(EnversServiceImpl.java:115)
      	at org.hibernate.envers.boot.internal.AdditionalJaxbMappingProducerImpl.produceAdditionalMappings(AdditionalJaxbMappingProducerImpl.java:99)
      	at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:288)
      	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:848)
      	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:875)
      	at org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44)
      	at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:167)
      	... 7 more
      

      Attachments

        Issue Links

          Activity

            People

              smarlow1@redhat.com Scott Marlow
              rhn-support-bmaxwell Brad Maxwell
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: