7 Replies Latest reply on Dec 20, 2011 4:19 PM by Brent Douglas

    InfinispanRegionFactory does not implement org.hibernate.cache.RegionFactory + Changes to hibernate provider requires dependency on org.jboss.msc and org.jboss.as.jpa.hibernate.infinispan in deployment?

    Brent Douglas Newbie

      First some background. Yesterday I was having issues with using infinispan for the second level cache after moving from a build from the 7.1.0.Beta1 tag to HEAD. I filed a bug (https://issues.jboss.org/browse/AS7-3080) erroneously and Scott Marlow pointed out this is the wrong thing to do and I should bring up bugs here.

       

      Following on from that I removed the line:

       

      <property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.infinispan.JndiInfinispanRegionFactory"/>

       

      from my persistence.xml files which resulted in the following stacktrace:

       

      09:55:47,262 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6) MSC00001: Failed to start service jboss.deployment.unit."pluto-resources.ear".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."pluto-resources.ear".INSTALL: Failed to process phase INSTALL of deployment "pluto-resources.ear"
           at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121) [jboss-as-server-7.1.0.CR1-SNAPSHOT.jar:]
           at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:]
           at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:]
           at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_26]
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_26]
           at java.lang.Thread.run(Thread.java:662) [:1.6.0_26]
      Caused by: java.lang.NoClassDefFoundError: org/jboss/msc/service/ServiceName
           at org.jboss.as.jpa.hibernate3.HibernatePersistenceProviderAdaptor.getCacheConfigServiceName(HibernatePersistenceProviderAdaptor.java:117)
           at org.jboss.as.jpa.hibernate3.HibernatePersistenceProviderAdaptor.getProviderDependencies(HibernatePersistenceProviderAdaptor.java:106)
           at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.addPuService(PersistenceUnitDeploymentProcessor.java:321)
           at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.handleEarDeployment(PersistenceUnitDeploymentProcessor.java:210)
           at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.deploy(PersistenceUnitDeploymentProcessor.java:119)
           at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115) [jboss-as-server-7.1.0.CR1-SNAPSHOT.jar:]
           ... 5 more
      Caused by: java.lang.ClassNotFoundException: org.jboss.msc.service.ServiceName from [Module "deployment.pluto-resources.ear:main" from Service Module Loader]
           at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.1.0.CR4]
           at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:485) [jboss-modules.jar:1.1.0.CR4]
           at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:444) [jboss-modules.jar:1.1.0.CR4]
           at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:421) [jboss-modules.jar:1.1.0.CR4]
           at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:143) [jboss-modules.jar:1.1.0.CR4]
           ... 11 more
      

       

      My understanding is that the hibernate adapters are conceptually copied into the deployment. Having a look at recent changes to the hibernate providers https://github.com/jbossas/jboss-as/commit/d005b39c50fb390ffe590a70b60fc4827cac3cca I see that the adapters now require org.jboss.msc.service.ServiceName and therefore so do all my deployments with hibernate. My first question is, is this correct? If so, I would be interested to have a discussion about whether it is the right thing to.

       

      Moving on I added a dependecy on org.jboss.msc in the deployment which resulted in:

       

      10:41:35,280 INFO  [org.hibernate.cfg.SettingsFactory] (MSC service thread 1-2) Cache region factory : org.jboss.as.jpa.hibernate.cache.infinispan.InfinispanRegionFactory
      10:41:35,280 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.persistenceunit."pluto-resources.ear#PlutoMainPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."pluto-resources.ear#PlutoMainPU": Failed to start service
                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1780) [jboss-msc-1.0.1.GA.jar:]
                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_26]
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_26]
                at java.lang.Thread.run(Thread.java:662) [:1.6.0_26]
      Caused by: javax.persistence.PersistenceException: [PersistenceUnit: PlutoMainPU] Unable to build EntityManagerFactory
                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915)
                at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
                at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:149)
                at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:79)
                at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:]
                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:]
                ... 3 more
      Caused by: org.hibernate.HibernateException: could not instantiate RegionFactory [org.jboss.as.jpa.hibernate.cache.infinispan.InfinispanRegionFactory]
                at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:423)
                at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:280)
                at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2863)
                at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2859)
                at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1870)
                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906)
                ... 8 more
      Caused by: java.lang.ClassNotFoundException: org.jboss.as.jpa.hibernate.cache.infinispan.InfinispanRegionFactory from [Module "deployment.pluto-resources.ear:main" from Service Module Loader]
                at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
                at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:485)
                at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:444)
                at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:421)
                at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:143)
                at java.lang.Class.forName0(Native Method) [:1.6.0_26]
                at java.lang.Class.forName(Class.java:169) [:1.6.0_26]
                at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192)
                at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:409)
                ... 13 more
      

       

      So I added a dependency on org.jboss.as.jpa.hibernate.infinispan. After that I get:

       

      10:39:08,514 INFO  [org.hibernate.cfg.SettingsFactory] (MSC service thread 1-16) Cache region factory : org.jboss.as.jpa.hibernate.cache.infinispan.InfinispanRegionFactory
      10:39:08,514 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-16) MSC00001: Failed to start service jboss.persistenceunit."pluto-resources.ear#PlutoMainPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."pluto-resources.ear#PlutoMainPU": Failed to start service
                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1780) [jboss-msc-1.0.1.GA.jar:]
                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_26]
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_26]
                at java.lang.Thread.run(Thread.java:662) [:1.6.0_26]
      Caused by: javax.persistence.PersistenceException: [PersistenceUnit: PlutoMainPU] Unable to build EntityManagerFactory
                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915)
                at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
                at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:149)
                at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:79)
                at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:]
                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:]
                ... 3 more
      Caused by: org.hibernate.HibernateException: could not instantiate RegionFactory [org.jboss.as.jpa.hibernate.cache.infinispan.InfinispanRegionFactory]
                at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:423)
                at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:280)
                at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2863)
                at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2859)
                at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1870)
                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906)
                ... 8 more
      Caused by: java.lang.ClassCastException: org.jboss.as.jpa.hibernate.cache.infinispan.InfinispanRegionFactory cannot be cast to org.hibernate.cache.RegionFactory
                at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:409)
                ... 13 more
      

       

      This appears to be because org.jboss.as.jpa.hibernate.cache.infinispan.InfinispanRegionFactory decends from org.hibernate.cache.spi.RegionFactory which is part of hibernate 4, and does not implement org.hibernate.cache.RegionFactory which is from hibernate 3. org.jboss.as.test.integration.jpa.hibernate.SecondLevelCacheTestCase would not pick this up as it uses hibernate 4.

       

      So finally, the TLDR is:

       

      - Is it right that I have included dependencies on org.jboss.msc and org.jboss.as.jpa.hibernate.infinispan?

      - If so, is it right that I should have to include them (more so with org.jboss.msc than the other).

      - I am planning on filing a bug saying that org.jboss.as.jpa.hibernate.cache.infinispan.InfinispanRegionFactory needs to implement org.hibernate.cache.RegionFactory at some level in the hirarchy. Should I proceed with this.

      - Should I file this under Infinispan or AS7 bug?

      - I am planning to file a bug about org.jboss.as.test.integration.jpa.hibernate.SecondLevelCacheTestCase not testing hibernate 3. Should I proceed with this.

       

      Thanks for your time.

       

      Brent Douglas