8 Replies Latest reply on Jul 26, 2013 10:39 AM by paolo.compieta

    AS7 and Dom4J

    kimtiago

      Hi,

       

      I'm with serious problems with JBoss AS 7.0.2

       

      In my project, I need to use Dom4J as dependency.

       

      When i add Dom4J in my classpath, i receive this error:

       

      {code}

      19:00:24,181 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC00001: Failed to start service jboss.persistenceunit."sgmj.

      war#sgmj": org.jboss.msc.service.StartException in service jboss.persistenceunit."sgmj.war#sgmj": Failed to start service
           at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1780) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_27]
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_27]
          at java.lang.Thread.run(Thread.java:662) [:1.6.0_27]
      Caused by: java.lang.ClassCastException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
           at org.dom4j.DocumentFactory.getInstance(DocumentFactory.java:97)
          at org.dom4j.DocumentHelper.getDocumentFactory(DocumentHelper.java:36)
          at org.dom4j.DocumentHelper.createDocument(DocumentHelper.java:41)
           at org.hibernate.envers.configuration.RevisionInfoConfiguration.generateDefaultRevisionInfoXmlMapping(RevisionInfoConfiguration.java:86)
          at org.hibernate.envers.configuration.RevisionInfoConfiguration.configure(RevisionInfoConfiguration.java:322)
           at org.hibernate.envers.configuration.AuditConfiguration.<init>(AuditConfiguration.java:94)
          at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:134)
          at org.hibernate.envers.event.EnversIntegrator.integrate(EnversIntegrator.java:63)
           at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:294)
          at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1722)
          at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:76)
           at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899)
          at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:884)
          at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
           at org.jboss.as.jpa.service.PersistenceUnitService.createContainerEntityManagerFactory(PersistenceUnitService.java:143)
          at org.jboss.as.jpa.service.PersistenceUnitService.start(PersistenceUnitService.java:77)
           at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
           ... 3 more

      {code}

       

      When i remove, i receive this error:

       

      {code}

      19:11:50,616 AVISO [javax.enterprise.resource.

      webcontainer.jsf.lifecycle] (http--127.0.0.1-8080-1) /teste.xhtml @21,85 listener="#{membroMjBean.buscaCep()}": java.lang.NoClassDefFoundError: org/dom4j/DocumentException: javax.el.ELException: /teste.xhtml @21,85 listener="#{membroMjBean.buscaCep()}": java.lang.NoClassDefFoundError: org/dom4j/DocumentException
           at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:111) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
          at org.primefaces.component.behavior.ajax.AjaxBehavior.broadcast(AjaxBehavior.java:169) [primefaces-3.0.M3.jar:]
           at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:760) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
          at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
           at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
          at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
           at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
          at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
          at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
           at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:139) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]
          at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]
           at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:49) [jboss-as-jpa-7.0.2.Final.jar:7.0.2.Final]
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:952) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
           at java.lang.Thread.run(Thread.java:662) [:1.6.0_27]
      Caused by: java.lang.NoClassDefFoundError: org/dom4j/DocumentException
          at org.sistemasmj.sgmj.model.beans.MembroMjBean.buscaCep(MembroMjBean.java:44) [classes:]
           at org.sistemasmj.sgmj.model.beans.MembroMjBean$Proxy$_$$_WeldClientProxy.buscaCep(MembroMjBean$Proxy$_$$_WeldClientProxy.java) [classes:]
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_27]
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_27]
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_27]
          at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_27]
           at org.apache.el.parser.AstValue.invoke(AstValue.java:196) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
          at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
           at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
          at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:56) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
           at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
          ... 26 more
      Caused by: java.lang.ClassNotFoundException: org.dom4j.DocumentException from [Module "deployment.sgmj.war:main" from Service Module Loader]
           at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191)
          at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:361)
          at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:333)
           at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310)
          at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:103)
          ... 37 more

      {code}

       

      I don't know what to do... I know AS7 has a module with Dom4J 1.6.1, the same version I need.

       

      If i put in classpath, AS7 don't like, if i remove, my application don't has Dom4J.

        • 1. Re: AS7 and Dom4J
          swd847

          The solution is to remove dom4j from the class path, and then add a

           

          Dependencies: org.dom4j

           

          to your MANIFEST.MF

           

          This will make the application servers dom4j availble to your application. For more see details https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7

          • 2. Re: AS7 and Dom4J
            swd847

            Are you bundling envars or using the application servers version? If you are using the app servers version having dom4j on the class path should not cause problems.

            • 3. Re: AS7 and Dom4J
              jason.greene

              Looks like the problem is a typical XML TCCL discovery gone awry. We need to patch hibernate envers to set TCCL to be hibernate's module classloader before constructing a dom4j instance. This will allow apps like yours to use your own version.

              • 4. Re: AS7 and Dom4J
                kimtiago

                Thanks a lot!!!

                 

                This resolved my problem! =)

                • 5. Re: AS7 and Dom4J
                  adamw

                  I looked through the rest of the Envers source and there are some other usages of the TCCL.

                  Do I understand correctly that:

                  * I should use TCCL when loading classes from the deployment (e.g. a custom listener which is specified in the configuration and deployed by the user with his app)

                  * For loading Envers-classes, use a class loader of e.g. the @Audited annotation, which comes in the Envers jar (e.g. a configuraiton option where users can specify one of the classes coming from the Envers jar).

                  ?

                   

                  Thanks,

                  Adam

                  • 6. Re: AS7 and Dom4J
                    hantsy

                    This does not work here.

                     

                    I added seam3 reports (and jasperreports) into myapplication, and excluded dom4j in pom.

                     

                    Either I added dom4j in jboss-deployment-structure.xml or war plugin configuration, the same problem occured.

                     

                     

                    maven-war-plugin

                    <archive>
                                                    <manifestEntries>
                                                        <Dependencies>org.dom4j</Dependencies>
                                                    </manifestEntries>
                                                </archive>
                    

                     

                     

                    jboss-deployment-structure.xml

                     

                    <jboss-deployment-structure>
                        <deployment>
                            <dependencies>
                                <module name="org.jboss.logmanager" />
                                <module name="org.dom4j" />
                            </dependencies>
                        </deployment>
                    </jboss-deployment-structure>
                    

                     

                     

                    The exception when I deployed the application into Jboss 7.0.2Final.

                     

                     

                    18:45:28,459 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.persistenceunit."siorc.war#siorcPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."siorc.war#siorcPU": Failed to start service
                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1780) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
                        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_29]
                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_29]
                        at java.lang.Thread.run(Thread.java:662) [:1.6.0_29]
                    Caused by: java.lang.ClassCastException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
                        at org.dom4j.DocumentFactory.getInstance(DocumentFactory.java:97)
                        at org.dom4j.DocumentHelper.getDocumentFactory(DocumentHelper.java:36)
                        at org.dom4j.DocumentHelper.createDocument(DocumentHelper.java:41)
                        at org.hibernate.envers.configuration.RevisionInfoConfiguration.generateDefaultRevisionInfoXmlMapping(RevisionInfoConfiguration.java:86)
                        at org.hibernate.envers.configuration.RevisionInfoConfiguration.configure(RevisionInfoConfiguration.java:322)
                        at org.hibernate.envers.configuration.AuditConfiguration.<init>(AuditConfiguration.java:94)
                        at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:134)
                        at org.hibernate.envers.event.EnversIntegrator.integrate(EnversIntegrator.java:63)
                        at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:294)
                        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1722)
                        at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:76)
                        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899)
                        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:884)
                        at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
                        at org.jboss.as.jpa.service.PersistenceUnitService.createContainerEntityManagerFactory(PersistenceUnitService.java:143)
                        at org.jboss.as.jpa.service.PersistenceUnitService.start(PersistenceUnitService.java:77)
                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
                        ... 3 more
                    
                    • 7. Re: AS7 and Dom4J
                      jason.greene

                      Adam Warski wrote:

                       

                      I looked through the rest of the Envers source and there are some other usages of the TCCL.

                      Do I understand correctly that:

                      * I should use TCCL when loading classes from the deployment (e.g. a custom listener which is specified in the configuration and deployed by the user with his app)

                      * For loading Envers-classes, use a class loader of e.g. the @Audited annotation, which comes in the Envers jar (e.g. a configuraiton option where users can specify one of the classes coming from the Envers jar).

                      ?

                       

                      Thanks,

                      Adam

                      That is correct.

                      • 8. Re: AS7 and Dom4J
                        paolo.compieta