5 Replies Latest reply on Nov 30, 2011 5:39 AM by lwen ma

    Use hibernate 3.5.6 as jpa provider but got a classloading error

    lwen ma Newbie

      I make a dir '/usr/local/jboss-as-7.0.2.Final/modules/org/hibernate/3/main', copy hibernate.jar into it, then make a module.xml file with following content:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <!-- Represents the Hibernate 3.x.x module--> 
      <module xmlns="urn:jboss:module:1.0" name="org.hibernate" slot="3">
          <resources>
              <resource-root path="hibernate.jar"/>
              <!-- Insert resources here -->
          </resources>
      
          <dependencies>
              <module name="asm.asm"/>
              <module name="javax.api"/>
              <module name="javax.persistence.api"/>
              <module name="javax.transaction.api"/>
              <module name="javax.validation.api"/>
              <module name="org.antlr"/>
              <module name="org.apache.commons.collections"/>
              <module name="org.dom4j"/>
              <module name="org.infinispan"/>
              <module name="org.javassist"/>
              <module name="org.jboss.as.jpa.hibernate" slot="3"/>
              <module name="org.jboss.logging"/>
          </dependencies>
      </module>
      

       

      but got error when start:

      11:43:03,665 WARN  [org.jboss.modules] (MSC service thread 1-3) Failed to define class org.jboss.as.jpa.hibernate3.JBossAppServerJtaPlatform in Module "org.jboss.as.jpa.hibernate:3" from local module loader @7f2a3793 (roots: /usr/local/jboss7/modules): java.lang.LinkageError: Failed to link org/jboss/as/jpa/hibernate3/JBossAppServerJtaPlatform (Module "org.jboss.as.jpa.hibernate:3" from local module loader @7f2a3793 (roots: /usr/local/jboss7/modules))
              at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:401) [jboss-modules.jar:1.0.2.GA]
              at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:261) [jboss-modules.jar:1.0.2.GA]
              at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:76) [jboss-modules.jar:1.0.2.GA]
              at org.jboss.modules.Module.loadModuleClass(Module.java:590) [jboss-modules.jar:1.0.2.GA]
              at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:183) [jboss-modules.jar:1.0.2.GA]
              at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:361) [jboss-modules.jar:1.0.2.GA]
              at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:333) [jboss-modules.jar:1.0.2.GA]
              at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310) [jboss-modules.jar:1.0.2.GA]
              at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:103) [jboss-modules.jar:1.0.2.GA]
              at org.jboss.as.jpa.hibernate3.HibernatePersistenceProviderAdaptor.injectJtaManager(HibernatePersistenceProviderAdaptor.java:49)
              at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.loadPersistenceAdapterModule(PersistenceUnitDeploymentProcessor.java:414)
              at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.getPersistenceProviderAdaptor(PersistenceUnitDeploymentProcessor.java:367)
              at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.addPuService(PersistenceUnitDeploymentProcessor.java:236)
              at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.handleJarDeployment(PersistenceUnitDeploymentProcessor.java:121)
              at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.deploy(PersistenceUnitDeploymentProcessor.java:102)
              at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115) [jboss-as-server-7.0.2.Final.jar:7.0.2.Final]
              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]
              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.NoClassDefFoundError: org/hibernate/transaction/JNDITransactionManagerLookup
              at java.lang.ClassLoader.defineClass1(Native Method) [:1.6.0_29]
              at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) [:1.6.0_29]
              at java.lang.ClassLoader.defineClass(ClassLoader.java:615) [:1.6.0_29]
              at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) [:1.6.0_29]
              at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:397) [jboss-modules.jar:1.0.2.GA]
              ... 20 more
      Caused by: java.lang.ClassNotFoundException: org.hibernate.transaction.JNDITransactionManagerLookup from [Module "org.jboss.as.jpa.hibernate:3" from local module loader @7f2a3793 (roots: /usr/local/jboss7/modules)]
              at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191) [jboss-modules.jar:1.0.2.GA]
              at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:361) [jboss-modules.jar:1.0.2.GA]
              at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:333) [jboss-modules.jar:1.0.2.GA]
              at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:333) [jboss-modules.jar:1.0.2.GA]
              at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310) [jboss-modules.jar:1.0.2.GA]
              at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:103) [jboss-modules.jar:1.0.2.GA]
              ... 25 more
      

       

       

       

      11:43:03,695 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.deployment.subunit."test.ear"."test_ejb.jar".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.subunit."test.ear"."test_ejb.jar".INSTALL: Failed to process phase INSTALL of subdeployment "mservices_ejb.jar" of deployment "mobee.ear"
              at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121) [jboss-as-server-7.0.2.Final.jar:7.0.2.Final]
              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]
              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.LinkageError: Failed to link org/jboss/as/jpa/hibernate3/JBossAppServerJtaPlatform (Module "org.jboss.as.jpa.hibernate:3" from local module loader @7f2a3793 (roots: /usr/local/jboss7/modules))
              at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:401)
              at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:261)
              at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:76)
              at org.jboss.modules.Module.loadModuleClass(Module.java:590)
              at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:183)
              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)
              at org.jboss.as.jpa.hibernate3.HibernatePersistenceProviderAdaptor.injectJtaManager(HibernatePersistenceProviderAdaptor.java:49)
              at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.loadPersistenceAdapterModule(PersistenceUnitDeploymentProcessor.java:414)
              at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.getPersistenceProviderAdaptor(PersistenceUnitDeploymentProcessor.java:367)
              at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.addPuService(PersistenceUnitDeploymentProcessor.java:236)
              at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.handleJarDeployment(PersistenceUnitDeploymentProcessor.java:121)
              at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.deploy(PersistenceUnitDeploymentProcessor.java:102)
              at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115) [jboss-as-server-7.0.2.Final.jar:7.0.2.Final]
              ... 5 more
      Caused by: java.lang.NoClassDefFoundError: org/hibernate/transaction/JNDITransactionManagerLookup
              at java.lang.ClassLoader.defineClass1(Native Method) [:1.6.0_29]
              at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) [:1.6.0_29]
              at java.lang.ClassLoader.defineClass(ClassLoader.java:615) [:1.6.0_29]
              at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) [:1.6.0_29]
              at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:397)
              ... 20 more
      Caused by: java.lang.ClassNotFoundException: org.hibernate.transaction.JNDITransactionManagerLookup from [Module "org.jboss.as.jpa.hibernate:3" from local module loader @7f2a3793 (roots: /usr/local/jboss7/modules)]
              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.performLoadClassChecked(ConcurrentClassLoader.java:333)
              at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310)
              at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:103)
              ... 25 more
      
        • 1. Re: Use hibernate 3.5.6 as jpa provider but got a classloading error
          Scott Marlow Master

          Maybe you just mispelled the hibernate jar name?  I think you need to change to:

           

           

          <?xml version="1.0" encoding="UTF-8"?>
          <!-- Represents the Hibernate 3.x.x module-->
          <module xmlns="urn:jboss:module:1.0" name="org.hibernate" slot="3">
              <resources>
                  <resource-root path="hibernate3.jar"/>
                  <!-- Insert resources here -->

              </resources>

              <dependencies>
                  <module name="asm.asm"/>
                  <module name="javax.api"/>
                  <module name="javax.persistence.api"/>
                  <module name="javax.transaction.api"/>
                  <module name="javax.validation.api"/>
                  <module name="org.antlr"/>
                  <module name="org.apache.commons.collections"/>
                  <module name="org.dom4j"/>
                  <module name="org.infinispan"/>
                  <module name="org.javassist"/>
                  <module name="org.jboss.as.jpa.hibernate" slot="3"/>
                  <module name="org.jboss.logging"/>

                           <module     name="org.slf4j"/>
              </dependencies>
          </module>


           

          Summary of changes above:

          1. renamed hibernate.jar to hibernate3.jar
          2. added org.slf4j dependency
          • 2. Re: Use hibernate 3.5.6 as jpa provider but got a classloading error
            lwen ma Newbie

            I'm ashamed of that spell mistake.

            Another mistake is that i shoule put module.xml and hibernate jar file in to dir '{jboss-home}/modules/org/hibernate/3' not ''{jboss-home}/modules/org/hibernate/3/main''.

             

            But I can't go forward even after I correct that errors.

             

            error log:

             


            11:10:19,356 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6) MSC00001: Failed to start service jboss.persistenceunit."test.ear/test_ejb.jar#testPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."test.ear/test_ejb.jar#testPU": 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.jboss.as.jpa.hibernate3.HibernateAnnotationScanner cannot be cast to org.hibernate.ejb.packaging.Scanner
                    at org.hibernate.ejb.Ejb3Configuration.buildScanner(Ejb3Configuration.java:410)
                    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:577)
                    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72)
                    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
            
            • 3. Re: Use hibernate 3.5.6 as jpa provider but got a classloading error
              Scott Marlow Master

              Hmm, check if the application already has a copy of the hibernate 3 jars also. 

              • 4. Re: Use hibernate 3.5.6 as jpa provider but got a classloading error
                lwen ma Newbie

                I check the ear's lib dir, no any hibernate jars, I think i'll build a sample ear to reproduce this issue. I'll attach it.