10 Replies Latest reply on Oct 5, 2011 2:35 AM by Mitja Skuhala

    JBoss 7.0.2 and hibernate 4.0.0 CR2

    Mitja Skuhala Newbie

      When i deploy my application i got this error:

       

       

      ERROR [org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer] (MSC service thread 1-1) HHH00142:Javassist Enhancement failed: si.xxx.sdp.subscriber.Permission: java.lang.RuntimeException: by java.lang.NoClassDefFoundError: org/hibernate/proxy/HibernateProxy

          at javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:509) [javassist-3.12.1.GA.jar:3.12.0.GA]

          at javassist.util.proxy.ProxyFactory.createClass2(ProxyFactory.java:486) [javassist-3.12.1.GA.jar:3.12.0.GA]

          at javassist.util.proxy.ProxyFactory.createClass1(ProxyFactory.java:422) [javassist-3.12.1.GA.jar:3.12.0.GA]

          at javassist.util.proxy.ProxyFactory.createClass(ProxyFactory.java:394) [javassist-3.12.1.GA.jar:3.12.0.GA]

          at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxyFactory(JavassistLazyInitializer.java:158) [hibernate-core-4.0.0.CR2.jar:4.0.0.CR2]

          at org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.postInstantiate(JavassistProxyFactory.java:63) [hibernate-core-4.0.0.CR2.jar:4.0.0.CR2]

          at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:218) [hibernate-core-4.0.0.CR2.jar:4.0.0.CR2]

          at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:211) [hibernate-core-4.0.0.CR2.jar:4.0.0.CR2]

          at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:81) [hibernate-core-4.0.0.CR2.jar:4.0.0.CR2]

          at sun.reflect.GeneratedConstructorAccessor20.newInstance(Unknown Source) [:1.6.0_20]

          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) [:1.6.0_20]

          at java.lang.reflect.Constructor.newInstance(Constructor.java:513) [:1.6.0_20]

          at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:135) [hibernate-core-4.0.0.CR2.jar:4.0.0.CR2]

          at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:188) [hibernate-core-4.0.0.CR2.jar:4.0.0.CR2]

          at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:334) [hibernate-core-4.0.0.CR2.jar:4.0.0.CR2]

          at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:496) [hibernate-core-4.0.0.CR2.jar:4.0.0.CR2]

          at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:141) [hibernate-core-4.0.0.CR2.jar:4.0.0.CR2]

          at sun.reflect.GeneratedConstructorAccessor21.newInstance(Unknown Source) [:1.6.0_20]

          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) [:1.6.0_20]

          at java.lang.reflect.Constructor.newInstance(Constructor.java:513) [:1.6.0_20]

          at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:158) [hibernate-core-4.0.0.CR2.jar:4.0.0.CR2]

          at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:131) [hibernate-core-4.0.0.CR2.jar:4.0.0.CR2]

          at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:343) [hibernate-core-4.0.0.CR2.jar:4.0.0.CR2]

          at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1722) [hibernate-core-4.0.0.CR2.jar:4.0.0.CR2]

          at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:76) [hibernate-entitymanager-4.0.0.CR2.jar:4.0.0.CR2]

          at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899) [hibernate-entitymanager-4.0.0.CR2.jar:4.0.0.CR2]

          at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:884) [hibernate-entitymanager-4.0.0.CR2.jar:4.0.0.CR2]

          at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73) [hibernate-entitymanager-4.0.0.CR2.jar:4.0.0.CR2]

          at org.jboss.as.jpa.service.PersistenceUnitService.createContainerEntityManagerFactory(PersistenceUnitService.java:143) [jboss-as-jpa-7.0.2.Final.jar:7.0.2.Final]

          at org.jboss.as.jpa.service.PersistenceUnitService.start(PersistenceUnitService.java:77) [jboss-as-jpa-7.0.2.Final.jar:7.0.2.Final]

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824)

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759)

          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_20]

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_20]

          at java.lang.Thread.run(Thread.java:619) [:1.6.0_20]

      Caused by: javassist.CannotCompileException: by java.lang.NoClassDefFoundError: org/hibernate/proxy/HibernateProxy

          at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:169) [javassist-3.12.1.GA.jar:3.12.0.GA]

          at javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:501) [javassist-3.12.1.GA.jar:3.12.0.GA]

          ... 34 more

      Caused by: java.lang.NoClassDefFoundError: org/hibernate/proxy/HibernateProxy

          at java.lang.ClassLoader.defineClass1(Native Method) [:1.6.0_20]

          at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) [:1.6.0_20]

          at java.lang.ClassLoader.defineClass(ClassLoader.java:616) [:1.6.0_20]

          at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) [:1.6.0_20]

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_20]

          at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_20]

          at javassist.util.proxy.FactoryHelper.toClass2(FactoryHelper.java:181) [javassist-3.12.1.GA.jar:3.12.0.GA]

          at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:163) [javassist-3.12.1.GA.jar:3.12.0.GA]

          ... 35 more

      Caused by: java.lang.ClassNotFoundException: org.hibernate.proxy.HibernateProxy from [Module "deployment.sdpear.ear.sdpcore.jar: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.performLoadClassChecked(ConcurrentClassLoader.java:333)

          at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310)

          at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:103)

          ... 43 more

       

      SDP.ear:

         |

         |--Core.jar (Entites and Interfaces)
         |
         |--EJBProj.jar (Stateless Beans )
         |       |

         |       | - META-INF/persitance.xml

         |

         |--WebProj.war (Where i'm testing servicese (Beans)

         |

       

      Persistance.xml:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <persistence version="2.0"

          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">

          <persistence-unit name="AS14Database">

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

              <properties>

                  <property name="hibernate.default_catalog" value="SOLID_DB_CATALOG" />

                  <property name="hibernate.default_schema" value="ITSOLID" />

                <!--   <property name="hibernate.hbm2ddl.auto" value="validate"/> -->

                  <property name="hibernate.dialect" value="org.hibernate.dialect.SolidSQLDialect" />

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

              </properties>

              <class>com.bla.Class1</class>

              <class>com.bla.Class2</class>

              <class>com.bla.Class3</class> 

          </persistence-unit>

      </persistence>

       

      This structure of my project worked iz JBoss 7.0.0,    in 7.0.1 and 7.0.2 at deploying i gor this error.

       

       

      First I thought that's error comes from Hibernate 4.0.0 CR2, and should worked in 7.0.1 (HIbernate 4.0.0 Beta5)...but it doesn't...So the error is in JBoss 7.0.1 and 7.0.2.

       

      I cann add Hibernate.jar to Deployment asembly...but this is not a solution

       

      Cann someone help me.

       

      I don't know how to fix this

        • 1. Re: JBoss 7.0.2 and hibernate 4.0.0 CR2
          Scott Marlow Master

          I wonder if you have older and newer Hibernate 4.0.0.x jars in the as7/modules/org/hibernate/main/ folder. 

           

          What jars do you see in your as7//modules/org/hibernate/main folder?

          • 2. Re: JBoss 7.0.2 and hibernate 4.0.0 CR2
            Mitja Skuhala Newbie

            jars:

             

            - hibernate-commons-annotations-4.0.0.CR2.jar

            - hibernate-core-4.0.0.CR2.jar

            - hibernate-entitymanager-4.0.0.CR2.jar

            - hibernate-infinispan-4.0.0.CR2.jar

            • 3. Re: JBoss 7.0.2 and hibernate 4.0.0 CR2
              Scott Marlow Master

              In the exception above, I'm puzzled by the mention of hibernate-core-4.0.0.Beta5.jar.  Could you also show the contents of as7/modules/org/hibernate/main/module.xml.

               

              Maybe also do a search for file hibernate-core-4.0.0.Beta5.jar on your machine and see where it could be coming from (either in as7/modules or elsewhere).

               

              Could you also check the setting of the JBOSS_HOME environment variable?  Make sure its pointing at the AS 7.0.2 installation.

              • 4. Re: JBoss 7.0.2 and hibernate 4.0.0 CR2
                Mitja Skuhala Newbie

                It looks like the javassist is not linked to hibernate in JBoss 7.0.1 and 7.0.2

                 

                the same error with diferent hibernate's: Beta5 in Jboss 7.0.1 and CR2 in 7.0.2
                .

                 

                In 7.0.0 (Beta1) works fine.

                 

                 

                 

                 

                ideas?

                • 5. Re: JBoss 7.0.2 and hibernate 4.0.0 CR2
                  Scott Marlow Master

                  Check your as7/modules/org/hibernate/main/module.xml, which should contain a dependency on the "org.javassist" module (jar should be in as7/modules/org/javassist/main folder).

                   

                  Looking at my AS7 build, I have the following contents in as7/modules/org/hibernate/main/module.xml (for the "org.hibernate" module):

                  <?xml version="1.0" encoding="UTF-8"?>

                   

                  <!--

                    ~ JBoss, Home of Professional Open Source.

                    ~ Copyright 2011, Red Hat, Inc., and individual contributors

                    ~ as indicated by the @author tags. See the copyright.txt file in the

                    ~ distribution for a full listing of individual contributors.

                    ~

                    ~ This is free software; you can redistribute it and/or modify it

                    ~ under the terms of the GNU Lesser General Public License as

                    ~ published by the Free Software Foundation; either version 2.1 of

                    ~ the License, or (at your option) any later version.

                    ~

                    ~ This software is distributed in the hope that it will be useful,

                    ~ but WITHOUT ANY WARRANTY; without even the implied warranty of

                    ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU

                    ~ Lesser General Public License for more details.

                    ~

                    ~ You should have received a copy of the GNU Lesser General Public

                    ~ License along with this software; if not, write to the Free

                    ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA

                    ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.

                    -->

                  <!-- Represents the Hibernate 4.0.x module-->

                  <module xmlns="urn:jboss:module:1.0" name="org.hibernate">

                      <resources>

                          <resource-root path="hibernate-core-4.0.0.CR2.jar"/>

                          <resource-root path="hibernate-commons-annotations-4.0.0.CR2.jar"/>

                          <resource-root path="hibernate-entitymanager-4.0.0.CR2.jar"/>

                          <resource-root path="hibernate-infinispan-4.0.0.CR2.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.ant"/>

                          <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="4"/>

                          <module name="org.jboss.logging"/>

                          <module name="org.hibernate.envers" services="import" optional = "true"/>

                      </dependencies>

                  </module>

                   

                  As you can see the "resource-root" entries describe the jars in the "org.hibernate" module.  The "dependencies" section specifies the other modules that are referenced from the "org.hibernate" module. 

                   

                  Did you understand my previous post? 

                   

                  Do you have further facts about how Hibernate Beta5 is being used in your installation (how are you switching between Beta5 + CR2)? 

                  • 6. Re: JBoss 7.0.2 and hibernate 4.0.0 CR2
                    Mitja Skuhala Newbie

                    I'm not switching betweb hibernate...i'm switching between Jbosses....and I posted error from 7.0.1 (Beta5)...my mistake.

                     

                    But the error is same in 7.0.1 and 7.0.2 only the name (*.jar) of hibernate is diferent...

                     

                     

                     

                     

                     

                    My modelu.xml  for hibernate it's the same like yours and like the original

                    • 7. Re: JBoss 7.0.2 and hibernate 4.0.0 CR2
                      Mitja Skuhala Newbie

                      I found a solution. Because of classNotFoundError i think it's a problem because my persistance unit (persistance.xml) and my Entityes are not in the same project....and yes, this is a source of my error.

                       

                      So if a hade to move Entities and persistance.xml in the same project and create a non-Entity classes, which are same like Entites without JPA anotation, and put them in my core.jar

                       

                       

                      SDP.ear:

                         |

                         |--Core.jar (Interfaces  and Classes (User.class, Phone.class,...))
                         |
                         |--EJBProj.jar (Stateless Beans, JPA entities(PhoneEntity.class, UserEntity.class) )
                         |       |

                         |       | - META-INF/persitance.xml

                         |

                         |--WebProj.war (Where i'm testing servicese (Beans)

                         |

                       

                       

                      Does someone know how to user normal classes and orm.xml ?

                       

                      <entity-mappings version="2.0" xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd">

                      </entity-mappings>

                      • 8. Re: JBoss 7.0.2 and hibernate 4.0.0 CR2
                        Scott Marlow Master

                        Could you try putting the persistence.xml into META-INFO of the sdpcore.jar and move sdpcore.jar into the ear/lib folder.

                         

                        The JPA 2.0 specification section 8.2 (persistence unit packaging) contains this note:

                         

                        NOTE: Java Persistence 1.0 supported use of a jar file in the root of the EAR as the root of a

                        persistence unit. This use is no longer supported. Portable applications should use the EAR

                        library directory for this case instead.

                        • 9. Re: JBoss 7.0.2 and hibernate 4.0.0 CR2
                          Scott Marlow Master

                          In my previous message, I was refering to moving the persistence.xml in the root of the EAR, to sdpcore (META-INF).

                          1 of 1 people found this helpful
                          • 10. Re: JBoss 7.0.2 and hibernate 4.0.0 CR2
                            Mitja Skuhala Newbie

                            Thank you,

                             

                            You helped me a lot with this.