3 Replies Latest reply on Dec 18, 2013 9:35 PM by xiang yingbing

    JBoss EAP 6.1 and hibernate.ejb.use_class_enhancer

    Lukasz Antoniak Newbie

      Hello Community,

       

      I have been trying to checkout the Hibernate's runtime entity class enhancement on EAP 6.1.0 platform. As first, I did not try to package any Hibernate version inside EAR archive. persistence.xml decriptor looks as follows:

      <persistence xmlns="http://java.sun.com/xml/ns/persistence"

                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"

                   version="2.0">

          <persistence-unit name="SampleJtaPu" transaction-type="JTA">

              <provider>org.hibernate.ejb.HibernatePersistence</provider>

              <jta-data-source>java:jboss/datasources/OracleDS</jta-data-source>

              <properties>

                  <property name="hibernate.ejb.use_class_enhancer" value="true" />

                  <property name="hibernate.show_sql" value="true" />

              </properties>

          </persistence-unit>

      </persistence>

       

      Deployment fails with below exception:

      15:21:42,419 ERROR [org.hibernate.bytecode.internal.javassist.JavassistClassTransformer] (ServerService Thread Pool -- 50) HHH000373: Unable to transform class: cannot find edu.lantoniak.entity.JtaEntity

      15:21:42,420 WARN  [org.jboss.modules] (ServerService Thread Pool -- 50) Failed to define class edu.lantoniak.entity.JtaEntityReference in Module "deployment.jpa-pu.ear.business-0.0.1.jar:main" from Service Module Loader: java.lang.ClassFormatError: Unable to transform class: cannot find edu.lantoniak.entity.JtaEntity

          at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:416) [jboss-modules.jar:1.2.0.Final-redhat-1]

          at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:260) [jboss-modules.jar:1.2.0.Final-redhat-1]

          at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:75) [jboss-modules.jar:1.2.0.Final-redhat-1]

          at org.jboss.modules.Module.loadModuleClass(Module.java:526) [jboss-modules.jar:1.2.0.Final-redhat-1]

          at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:188) [jboss-modules.jar:1.2.0.Final-redhat-1]

          at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:444) [jboss-modules.jar:1.2.0.Final-redhat-1]

          at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:432) [jboss-modules.jar:1.2.0.Final-redhat-1]

          at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:374) [jboss-modules.jar:1.2.0.Final-redhat-1]

          at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:119) [jboss-modules.jar:1.2.0.Final-redhat-1]

          at org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:165) [hibernate-core-4.2.0.Final-redhat-1.jar:4.2.0.Final-redhat-1]

          at org.hibernate.ejb.Ejb3Configuration.classForName(Ejb3Configuration.java:1333) [hibernate-entitymanager-4.2.0.Final-redhat-1.jar:4.2.0.Final-redhat-1]

          at org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1405) [hibernate-entitymanager-4.2.0.Final-redhat-1.jar:4.2.0.Final-redhat-1]

          at org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:1199) [hibernate-entitymanager-4.2.0.Final-redhat-1.jar:4.2.0.Final-redhat-1]

          at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:1063) [hibernate-entitymanager-4.2.0.Final-redhat-1.jar:4.2.0.Final-redhat-1]

          at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:701) [hibernate-entitymanager-4.2.0.Final-redhat-1.jar:4.2.0.Final-redhat-1]

          at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:91) [hibernate-entitymanager-4.2.0.Final-redhat-1.jar:4.2.0.Final-redhat-1]

          at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:200) [jboss-as-jpa-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

          at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$600(PersistenceUnitServiceImpl.java:57) [jboss-as-jpa-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

          at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:99) [jboss-as-jpa-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_21]

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_21]

          at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_21]

          at org.jboss.threads.JBossThread.run(JBossThread.java:122)

      Caused by: java.lang.instrument.IllegalClassFormatException: Unable to transform class: cannot find edu.lantoniak.entity.JtaEntity

          at org.hibernate.ejb.instrument.InterceptFieldClassFileTransformer.transform(InterceptFieldClassFileTransformer.java:79) [hibernate-entitymanager-4.2.0.Final-redhat-1.jar:4.2.0.Final-redhat-1]

          at org.jboss.as.jpa.classloader.JPADelegatingClassFileTransformer.transform(JPADelegatingClassFileTransformer.java:48) [jboss-as-jpa-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

          at org.jboss.as.server.deployment.module.DelegatingClassFileTransformer.transform(DelegatingClassFileTransformer.java:60)

          at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:414) [jboss-modules.jar:1.2.0.Final-redhat-1]

          ... 22 more

       

      15:21:42,429 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 50) MSC000001: Failed to start service jboss.persistenceunit."jpa-pu.ear/business-0.0.1.jar#SampleJtaPu": org.jboss.msc.service.StartException in service jboss.persistenceunit."jpa-pu.ear/business-0.0.1.jar#SampleJtaPu": javax.persistence.PersistenceException: [PersistenceUnit: SampleJtaPu] class or package not found

          at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:103) [jboss-as-jpa-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_21]

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_21]

          at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_21]

          at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.0.Final-redhat-1.jar:2.1.0.Final-redhat-1]

      Caused by: javax.persistence.PersistenceException: [PersistenceUnit: SampleJtaPu] class or package not found

          at org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1416)

          at org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:1199)

          at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:1063)

          at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:701)

          at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:91)

          at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:200) [jboss-as-jpa-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

          at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$600(PersistenceUnitServiceImpl.java:57) [jboss-as-jpa-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

          at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:99) [jboss-as-jpa-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

          ... 4 more

      Caused by: java.lang.ClassNotFoundException: edu.lantoniak.entity.JtaEntityReference from [Module "org.hibernate:main" from local module loader @a303147 (finder: local module finder @61f3318a (roots: /opt/jboss-eap-6.1/modules,/opt/jboss-eap-6.1/modules/system/layers/base))]

          at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:196) [jboss-modules.jar:1.2.0.Final-redhat-1]

          at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:444) [jboss-modules.jar:1.2.0.Final-redhat-1]

          at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:432) [jboss-modules.jar:1.2.0.Final-redhat-1]

          at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:374) [jboss-modules.jar:1.2.0.Final-redhat-1]

          at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:119) [jboss-modules.jar:1.2.0.Final-redhat-1]

          at java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_21]

          at java.lang.Class.forName(Class.java:266) [rt.jar:1.7.0_21]

          at org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:170)

          at org.hibernate.ejb.Ejb3Configuration.classForName(Ejb3Configuration.java:1333)

          at org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1405)

          ... 11 more

       

      15:21:42,639 ERROR [org.jboss.as.server] (HttpManagementService-threads - 1) JBAS015870: Deploy of deployment "jpa-pu.ear" was rolled back with the following failure message:

      {"JBAS014671: Failed services" => {"jboss.persistenceunit.\"jpa-pu.ear/business-0.0.1.jar#SampleJtaPu\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"jpa-pu.ear/business-0.0.1.jar#SampleJtaPu\": javax.persistence.PersistenceException: [PersistenceUnit: SampleJtaPu] class or package not found

          Caused by: javax.persistence.PersistenceException: [PersistenceUnit: SampleJtaPu] class or package not found

          Caused by: java.lang.ClassNotFoundException: edu.lantoniak.entity.JtaEntityReference from [Module \"org.hibernate:main\" from local module loader @a303147 (finder: local module finder @61f3318a (roots: /opt/jboss-eap-6.1/modules,/opt/jboss-eap-6.1/modules/system/layers/base))]"}}

       

      I have been trying to ship Hibernate inside EAR archive, configure jboss-deployment-structure.xml descriptor, but no happy ending. Everything works fine when hibernate.ejb.use_class_enhancer equals false.

       

      Any ideas?

       

      Best regards,

      Lukasz