10 Replies Latest reply on Aug 20, 2015 2:42 AM by Alexander Ott

    Wildfly 8.2.1 Final JPA 2.1

    Alexander Ott Newbie

      Hello,

       

      we are currently trying to migrate from JBoss 5.1.0 to Wildfly 8.2.1. We tryed to use the bundled Hibernate 4.3.7.Final (JPA 2.1) but we have the problem (class is mapped more than once) which was referenced here [HHH-8775] Exception when mapping a class more than once - Hibernate JIRA.

       

      So we tryed to use Hibernate 4.2.19(JPA 2.0). Therefore we added the following libs into modules\system\layers\base\org\hibernate\4.1 with the following module.xml

       

      <!-- Represents the Hibernate 4.1.x (works with Hibernate 4.2.x jars also) module  -->
      <module xmlns="urn:jboss:module:1.3" name="org.hibernate" slot="4.1">
          <resources>
        <resource-root path="hibernate-core-4.2.19.Final.jar"/>
              <resource-root path="hibernate-envers-4.2.19.Final.jar"/>
              <resource-root path="hibernate-entitymanager-4.2.19.Final.jar"/>
              <resource-root path="hibernate-infinispan-4.2.19.Final.jar"/>
              <resource-root path="jipijapa-hibernate4-1-1.0.1.Final.jar"/>
          </resources>
      
      
          <dependencies>
              <module name="asm.asm"/>
              <module name="javax.api"/>
              <module name="javax.annotation.api"/>
              <module name="javax.enterprise.api"/>
              <module name="javax.persistence.api"/>
              <module name="javax.transaction.api"/>
              <module name="javax.validation.api"/>
              <module name="javax.xml.bind.api"/>
              <module name="org.antlr"/>
              <module name="org.apache.commons.collections"/>
              <module name="org.dom4j"/>
              <module name="org.infinispan" services="import"/>
              <module name="org.javassist"/>
              <module name="org.jboss.as.jpa.spi"/>
              <module name="org.jboss.jandex"/>
              <module name="org.jboss.logging"/>
              <module name="org.jboss.vfs"/>
              <module name="org.hibernate.commons-annotations"/>
          </dependencies>
      </module>
      

       

      Our persistence.xml looks like this:

       

      <?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="rsPU">
          <!-- JPA 2.0 -->
          <provider>org.hibernate.ejb.HibernatePersistence</provider>
          <jta-data-source>java:jboss/datasources/FESAD_DS</jta-data-source>
          <jar-file>fesadCatalogingInterfaces.jar</jar-file>
          <jar-file>fesadDictionaryInterfaces.jar</jar-file>
          <jar-file>fesadDossierInterfaces.jar</jar-file>
          <jar-file>fesadMacroInterfaces.jar</jar-file>
          <jar-file>fesadMasterdataInterfaces.jar</jar-file>
          <jar-file>fesadOrderprocessingInterfaces.jar</jar-file>
          <jar-file>fesadPreviewInterfaces.jar</jar-file>
          <jar-file>fesadRetrievalInterfaces.jar</jar-file>
          <jar-file>fesadUserInterfaces.jar</jar-file>
          <jar-file>fesadGlobalInternalInterfaces.jar</jar-file>
          <jar-file>../fesadNormDBValueImpl.jar</jar-file>
          <properties>
            <property name="jboss.as.jpa.providerModule" value="org.hibernate:4.1" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
            <property name="javax.persistence.jdbc.driver" value="com.jdbc.driver.OracleDriver"/>
            <property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver"/>
            <property name="hibernate.show_sql" value="false"/>
            <property name="hibernate.max_fetch_depth" value="5"/>
            <property name="hibernate.jdbc.batch_size" value="100"/>
            <property name="hibernate.jdbc.batch_versioned_data" value="false"/>
            <property name="hibernate.jdbc.use_get_generated_keys" value="true"/>
            <property name="hibernate.use_sql_comments" value="false"/>
            <property name="hibernate.ScanForMappingsEnabled" value="true"/>
            <property name="hibernate.generate_statistics" value="false"/>
            <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/>
            <property name="hibernate.bytecode.use_reflection_optimizer" value="true"/>
            <property name="jboss.entity.manager.jndi.name" value="java:/rsPU"/>
            <property name="jboss.entity.manager.factory.jndi.name" value="java:/rsPUEntityManagerFactory"/>
            <property name="hibernate.jdbc.use_streams_for_binary" value="true"/>
      
      
            <property name="hibernate.cache.use_second_level_cache" value="true"/>
            <property name="hibernate.cache.use_query_cache" value="true"/>
            <property name="hibernate.cache.use_structured_entries" value="false"/>
            <property name="hibernate.cache.use_minimal_puts" value="true"/>
            
            <property name="hibernate.cache.region_prefix" value="rsPU"/>
            
          </properties>
        </persistence-unit>
      </persistence>
      

       

       

      On Server startup we get the following error:

       

      16:24:56,897 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 63) MSC000001: Failed to start service jboss.persistenceunit."200_fesadbean.ear#rsPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."200_fesadbean.ear#rsPU": org.hibernate.annotations.common.reflection.ClassLoadingException: Unable to load Class [de.ard.sad.fesad.cataloging.docUnit.interfaces.package-info]
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:172) [wildfly-jpa-8.2.1.Final.jar:8.2.1.Final]
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117) [wildfly-jpa-8.2.1.Final.jar:8.2.1.Final]
        at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.7.0_75]
        at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:474)
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182) [wildfly-jpa-8.2.1.Final.jar:8.2.1.Final]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_75]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_75]
        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_75]
        at org.jboss.threads.JBossThread.run(JBossThread.java:122)
      Caused by: org.hibernate.annotations.common.reflection.ClassLoadingException: Unable to load Class [de.ard.sad.fesad.cataloging.docUnit.interfaces.package-info]
        at org.hibernate.annotations.common.util.StandardClassLoaderDelegateImpl.classForName(StandardClassLoaderDelegateImpl.java:60) [hibernate-commons-annotations-4.0.4.Final.jar:4.0.4.Final]
        at org.hibernate.annotations.common.reflection.java.JavaReflectionManager.packageForName(JavaReflectionManager.java:147) [hibernate-commons-annotations-4.0.4.Final.jar:4.0.4.Final]
        at org.hibernate.cfg.AnnotationBinder.bindPackage(AnnotationBinder.java:260) [hibernate-core-4.2.19.Final.jar:4.2.19.Final]
        at org.hibernate.cfg.Configuration.addPackage(Configuration.java:788) [hibernate-core-4.2.19.Final.jar:4.2.19.Final]
        at org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:1236) [hibernate-entitymanager-4.2.19.Final.jar:4.2.19.Final]
        at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:1058) [hibernate-entitymanager-4.2.19.Final.jar:4.2.19.Final]
        at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:703) [hibernate-entitymanager-4.2.19.Final.jar:4.2.19.Final]
        at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:75) [hibernate-entitymanager-4.2.19.Final.jar:4.2.19.Final]
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:318) [wildfly-jpa-8.2.1.Final.jar:8.2.1.Final]
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$1100(PersistenceUnitServiceImpl.java:67) [wildfly-jpa-8.2.1.Final.jar:8.2.1.Final]
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:167) [wildfly-jpa-8.2.1.Final.jar:8.2.1.Final]
        ... 8 more
      Caused by: java.lang.ClassNotFoundException: de.ard.sad.fesad.cataloging.docUnit.interfaces.package-info from [Module "org.hibernate.commons-annotations:main" from local module loader @192328ef (finder: local module finder @53546fcd (roots: C:\dev\server\wildfly-8.2.1.Final\modules,C:\dev\server\wildfly-8.2.1.Final\modules\system\layers\base))]
        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final]
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final]
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final]
        at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final]
        at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final]
        at java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_75]
        at java.lang.Class.forName(Class.java:274) [rt.jar:1.7.0_75]
        at org.hibernate.annotations.common.util.StandardClassLoaderDelegateImpl.classForName(StandardClassLoaderDelegateImpl.java:57) [hibernate-commons-annotations-4.0.4.Final.jar:4.0.4.Final]
        ... 18 more
      

       

       

      Any ideas to solve this problem? May we configured anything wrong with the hibernate 4.1 slot?

        • 1. Re: Wildfly 8.2.1 Final JPA 2.1
          jaikiran pai Master

          Caused by: java.lang.ClassNotFoundException: de.ard.sad.fesad.cataloging.docUnit.interfaces.package-info

          I vaguely remember there was a bug related to this. I'll have to check if it was in WildFly or in Hibernate.

          • 2. Re: Wildfly 8.2.1 Final JPA 2.1
            Alexander Ott Newbie

            It seems to be a problem with hibernate-commons-annotations-4.0.4.Final.jar which is bundled with wildfly 8.2.1. I added hibernate-commons-annotations-4.0.2.Final.jar as slot 4 to \modules\system\layers\base\org\hibernate\commons-annotations\4 and linked it in module.xml of modules\system\layers\base\org\hibernate\4.1further more i updated to hibernate 4.2.20.Final

             

            <!-- Represents the Hibernate 4.1.x (works with Hibernate 4.2.x jars also) module  -->
            <module xmlns="urn:jboss:module:1.3" name="org.hibernate" slot="4.1">
                <resources>
              <resource-root path="hibernate-core-4.2.20.Final.jar"/>
                    <resource-root path="hibernate-envers-4.2.20.Final.jar"/>
                    <resource-root path="hibernate-entitymanager-4.2.20.Final.jar"/>
                    <resource-root path="hibernate-infinispan-4.2.20.Final.jar"/>
                    <resource-root path="jipijapa-hibernate4-1-1.0.1.Final.jar"/>
                </resources>
            
            
                <dependencies>
                    <module name="asm.asm"/>
                    <module name="javax.api"/>
                    <module name="javax.annotation.api"/>
                    <module name="javax.enterprise.api"/>
                    <module name="javax.persistence.api"/>
                    <module name="javax.transaction.api"/>
                    <module name="javax.validation.api"/>
                    <module name="javax.xml.bind.api"/>
                    <module name="org.antlr"/>
                    <module name="org.apache.commons.collections"/>
                    <module name="org.dom4j"/>
                    <module name="org.infinispan" services="import"/>
                    <module name="org.javassist"/>
                    <module name="org.jboss.as.jpa.spi"/>
                    <module name="org.jboss.jandex"/>
                    <module name="org.jboss.logging"/>
                    <module name="org.jboss.vfs"/>
                    <module name="org.hibernate.commons-annotations" slot="4"/>
                </dependencies>
            </module>
            

             

             

            But now i got the next error:

             

            08:41:22,490 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 62) MSC000001: Failed to start service jboss.persistenceunit."200_fesadbean.ear#rsPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."200_fesadbean.ear#rsPU": javax.persistence.PersistenceException: [PersistenceUnit: rsPU] Unable to build EntityManagerFactory
              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:172) [wildfly-jpa-8.2.1.Final.jar:8.2.1.Final]
              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117) [wildfly-jpa-8.2.1.Final.jar:8.2.1.Final]
              at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.7.0_75]
              at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:474)
              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182) [wildfly-jpa-8.2.1.Final.jar:8.2.1.Final]
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_75]
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_75]
              at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_75]
              at org.jboss.threads.JBossThread.run(JBossThread.java:122)
            Caused by: javax.persistence.PersistenceException: [PersistenceUnit: rsPU] Unable to build EntityManagerFactory
              at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:925) [hibernate-entitymanager-4.2.20.Final.jar:4.2.20.Final]
              at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:900) [hibernate-entitymanager-4.2.20.Final.jar:4.2.20.Final]
              at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:76) [hibernate-entitymanager-4.2.20.Final.jar:4.2.20.Final]
              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:318) [wildfly-jpa-8.2.1.Final.jar:8.2.1.Final]
              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$1100(PersistenceUnitServiceImpl.java:67) [wildfly-jpa-8.2.1.Final.jar:8.2.1.Final]
              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:167) [wildfly-jpa-8.2.1.Final.jar:8.2.1.Final]
              ... 8 more
            Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.spi.CacheImplementor]
              at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:211) [hibernate-core-4.2.20.Final.jar:4.2.20.Final]
              at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:175) [hibernate-core-4.2.20.Final.jar:4.2.20.Final]
              at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:156) [hibernate-core-4.2.20.Final.jar:4.2.20.Final]
              at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:267) [hibernate-core-4.2.20.Final.jar:4.2.20.Final]
              at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1799) [hibernate-core-4.2.20.Final.jar:4.2.20.Final]
              at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:96) [hibernate-entitymanager-4.2.20.Final.jar:4.2.20.Final]
              at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915) [hibernate-entitymanager-4.2.20.Final.jar:4.2.20.Final]
              ... 13 more
            Caused by: org.hibernate.cache.CacheException: Unable to start region factory
              at org.hibernate.cache.infinispan.InfinispanRegionFactory.start(InfinispanRegionFactory.java:323) [hibernate-infinispan-4.2.20.Final.jar:4.2.20.Final]
              at org.hibernate.internal.CacheImpl.<init>(CacheImpl.java:70) [hibernate-core-4.2.20.Final.jar:4.2.20.Final]
              at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:40) [hibernate-core-4.2.20.Final.jar:4.2.20.Final]
              at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:35) [hibernate-core-4.2.20.Final.jar:4.2.20.Final]
              at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.initiateService(SessionFactoryServiceRegistryImpl.java:91) [hibernate-core-4.2.20.Final.jar:4.2.20.Final]
              at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:201) [hibernate-core-4.2.20.Final.jar:4.2.20.Final]
              ... 19 more
            Caused by: java.lang.NoClassDefFoundError: org/infinispan/config/Configuration
              at org.hibernate.cache.infinispan.TypeOverrides.createInfinispanConfiguration(TypeOverrides.java:122) [hibernate-infinispan-4.2.20.Final.jar:4.2.20.Final]
              at org.hibernate.cache.infinispan.InfinispanRegionFactory.defineGenericDataTypeCacheConfigurations(InfinispanRegionFactory.java:490) [hibernate-infinispan-4.2.20.Final.jar:4.2.20.Final]
              at org.hibernate.cache.infinispan.InfinispanRegionFactory.start(InfinispanRegionFactory.java:318) [hibernate-infinispan-4.2.20.Final.jar:4.2.20.Final]
              ... 24 more
            Caused by: java.lang.ClassNotFoundException: org.infinispan.config.Configuration from [Module "org.hibernate:4.1" from local module loader @192328ef (finder: local module finder @53546fcd (roots: C:\dev\server\wildfly-8.2.1.Final\modules,C:\dev\server\wildfly-8.2.1.Final\modules\system\layers\base))]
              at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final]
              at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final]
              at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final]
              at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final]
              at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final]
              ... 27 more
            

             

             

            Do i also need a special version of infinispan for hibernate 4.2.20?

            • 3. Re: Wildfly 8.2.1 Final JPA 2.1
              Alexander Ott Newbie

              Caused by the issues with integrating hibernate 4.2.20.Final we now changed some mappings to solve the issue [HHH-8775] Exception when mapping a class more than once - Hibernate JIRA. Our deployment seems to work now with Hibernate 4.3.7.Final until we include our EventListeners.


              At JBoss 5.1.0 we used org.hibernate.event.Initializable of Hibernate 3.3.2 to initialize some stuff (see below) via org.hibernate.event.Initializable.


              public void initialize( Configuration cfg )
                  {
                      synchronized ( mutextInitializationInProgress )
                      {
                          if ( dataAccessConfig == null )
                          {
                              dataAccessConfig = AccessRightUtils.createDataAccessConfig( cfg );
                          }
                      }
                  }
              
              


              Is there anything comparable in Hibernate 4.3.7? Maybe within our implementation of org.hibernate.integrator.spi.Integrator which is used to register our eventListeners


              @Override
              public void integrate( Configuration configuration, SessionFactoryImplementor sessionFactory,
                SessionFactoryServiceRegistry serviceRegistry )
              {
                  ....
              }
              
              
              • 4. Re: Wildfly 8.2.1 Final JPA 2.1
                jaikiran pai Master

                 

                Alexander Ott wrote:

                 

                 

                At JBoss 5.1.0 we used org.hibernate.event.Initializable of Hibernate 3.3.2 to initialize some stuff (see below) via org.hibernate.event.Initializable.


                1. public void initialize( Configuration cfg ) 
                2.     { 
                3.         synchronized ( mutextInitializationInProgress ) 
                4.         { 
                5.             if ( dataAccessConfig == null
                6.             { 
                7.                 dataAccessConfig = AccessRightUtils.createDataAccessConfig( cfg ); 
                8.             } 
                9.         } 
                10.     } 

                 

                Is there anything comparable in Hibernate 4.3.7?

                 

                Someone more knowledgeable in Hibernate, like smarlow or sebersole might be able to answer that.

                • 5. Re: Wildfly 8.2.1 Final JPA 2.1
                  Scott Marlow Master

                  Not really sure but https://hibernate.atlassian.net/browse/HHH-6030 mentions using Hibernate ORM's Integrator instead:

                  • 6. Re: Wildfly 8.2.1 Final JPA 2.1
                    Steve Ebersole Apprentice

                    Well, in the Integrator you could just simply perform that work, no?  E.g.,

                     

                    @Override
                    public void integrate( 
                              Configuration configuration,
                              SessionFactoryImplementor sessionFactory, 
                              SessionFactoryServiceRegistry serviceRegistry) {
                         EventListenerRegistry listeners = serviceRegistry.getService( EventListenerRegistry.class );
                    
                         MyCustomListener mcl = new MyCustomListener();
                         mcl.initialize( configuration );
                         listeners.appendListeners( EventType.PERSIST, mcl );
                    
                         ...
                    }
                    
                    

                     

                    Although given this code, I'd prefer something like:

                    @Override
                    public void integrate( 
                              Configuration configuration,
                              SessionFactoryImplementor sessionFactory, 
                              SessionFactoryServiceRegistry serviceRegistry) {
                         EventListenerRegistry listeners = serviceRegistry.getService( EventListenerRegistry.class );
                    
                    
                         listeners.appendListeners( 
                                   EventType.PERSIST,
                                   MyCustomListener.build( configuration )
                    
                         );
                    
                    
                         ...
                    
                    }
                    
                    
                    • 7. Re: Wildfly 8.2.1 Final JPA 2.1
                      Alexander Ott Newbie

                      Yes, it works as you expected!

                       

                      This was my way of integration first.

                      @Override  
                      public void integrate(   
                                Configuration configuration,  
                                SessionFactoryImplementor sessionFactory,   
                                SessionFactoryServiceRegistry serviceRegistry) {  
                           EventListenerRegistry listeners = serviceRegistry.getService( EventListenerRegistry.class );  
                      
                           listeners.appendListeners( EventType.PERSIST, MyCustomListener.class);  
                        
                           ...  
                      }  
                      
                      

                      But it is also possible as you described!

                      @Override  
                      public void integrate(   
                                Configuration configuration,  
                                SessionFactoryImplementor sessionFactory,   
                                SessionFactoryServiceRegistry serviceRegistry) {  
                           EventListenerRegistry listeners = serviceRegistry.getService( EventListenerRegistry.class );  
                        
                           MyCustomListener mcl = new MyCustomListener();  
                           mcl.initialize( configuration );  
                           listeners.appendListeners( EventType.PERSIST, mcl );  
                        
                           ...  
                      }  
                      
                      

                       

                      Thanks!

                      • 8. Re: Wildfly 8.2.1 Final JPA 2.1
                        Alexander Ott Newbie

                        What is about org.hibernate.ejb.event.EJB3*EventListeners in Hibernate 4.3? I can't find them anywhere. In Hibenate 3.3.2 we used the following EJB3EventListeners

                         

                        • org.hibernate.ejb.event.EJB3FlushEventListener
                        • org.hibernate.ejb.event.EJB3PostUpdateEventListener
                        • org.hibernate.ejb.event.EJB3PostInsertEventListener
                        • org.hibernate.ejb.event.EJB3PostDeleteEventListener
                        • org.hibernate.ejb.event.EJB3MergeEventListener
                        • 9. Re: Wildfly 8.2.1 Final JPA 2.1
                          Steve Ebersole Apprentice
                          • org.hibernate.jpa.event.internal.core.JpaFlushEventListener
                          • org.hibernate.jpa.event.internal.core.JpaPostUpdateEventListener
                          • ...

                           

                          Note especially the 'internal' package designation.

                          1 of 1 people found this helpful
                          • 10. Re: Wildfly 8.2.1 Final JPA 2.1
                            Alexander Ott Newbie

                            sebersole thanks for your help so far! May you can help me with another issue?

                             

                            In Hibernate 3.3 we created IdentifierGenerator as followed

                             

                            final Properties properties = new Properties();
                            properties.setProperty( "sequence_name", sequenceName );
                            properties.setProperty( "increment_size", "20" );
                            properties.setProperty( "optimizer", "pooled" );
                            return IdentifierGeneratorFactory.create( "org.hibernate.id.enhanced.SequenceStyleGenerator", Hibernate.LONG,
                              properties, new FesadOracleDialect() );
                            

                             

                            In Hibernate 4.3 we change it as seen in the following snippet

                            final Properties properties = new Properties();
                            properties.setProperty( "sequence_name", sequenceName );
                            properties.setProperty( "increment_size", "20" );
                            properties.setProperty( "optimizer", "pooled" );
                            org.hibernate.id.enhanced.SequenceStyleGenerator gen = new org.hibernate.id.enhanced.SequenceStyleGenerator();
                            gen.configure( new LongType(), properties, new FesadOracleDialect() );
                            return gen;
                            

                             

                            But we get NPE at org.hibernate.id.enhanced.SequenceStyleGenerator:286 (see following snippet lineno 9) cause there is no ObjectNameNormalizer stored in the params. Do we have to create our own instance of ObjectNameNormalizer or can we get it anyway from hibernate?

                            final String sequencePerEntitySuffix = ConfigurationHelper.getString( CONFIG_SEQUENCE_PER_ENTITY_SUFFIX, params, DEF_SEQUENCE_SUFFIX );
                            // JPA_ENTITY_NAME value honors <class ... entity-name="..."> (HBM) and @Entity#name (JPA) overrides.
                            String sequenceName = ConfigurationHelper.getBoolean( CONFIG_PREFER_SEQUENCE_PER_ENTITY, params, false )
                              ? params.getProperty( JPA_ENTITY_NAME ) + sequencePerEntitySuffix
                              : DEF_SEQUENCE_NAME;
                            final ObjectNameNormalizer normalizer = (ObjectNameNormalizer) params.get( IDENTIFIER_NORMALIZER );
                            sequenceName = ConfigurationHelper.getString( SEQUENCE_PARAM, params, sequenceName );
                            if ( sequenceName.indexOf( '.' ) < 0 ) {
                              sequenceName = normalizer.normalizeIdentifierQuoting( sequenceName );
                               final String schemaName = params.getProperty( SCHEMA );
                               final String catalogName = params.getProperty( CATALOG );
                              sequenceName = Table.qualify(
                              dialect.quote( catalogName ),
                              dialect.quote( schemaName ),
                              dialect.quote( sequenceName )
                              );
                            }
                            // if already qualified there is not much we can do in a portable manner so we pass it
                            // through and assume the user has set up the name correctly.
                            
                            return sequenceName;