2 Replies Latest reply on Jul 1, 2013 2:33 PM by Richard Doust

    Moving from 4.2.2 to AS 7

    Richard Doust Newbie

      Hi all,

       

      I am still working on my move from 4.2.2 to AS 7. I am making slow and painful progress. My latest problem is that when JBoss starts I get an exception. Initially the exception said that I had not defined a 2nd level cache. I did some searching and found advice tellme to add:

       

            <shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>

           .

           .

           .

              <property name="hibernate.cache.infinispan.cachemanager" value="java:jboss/infinispan/hibernate"/>

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



      to my persistence.xml. I did that. Now I get this exception:

       

      12:03:30,470 INFO  [org.hibernate.cache.infinispan.JndiInfinispanRegionFactory] (MSC service thread 1-14) Unable to retrieve CacheManager from JNDI [java:jboss/infinispan/hibernate]: javax.naming.NameNotFoundException: infinispan/hibernate -- service jboss.naming.context.java.jboss.infinispan.hibernate

                at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:97)

                at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:178)

                at org.jboss.as.naming.InitialContext.lookup(InitialContext.java:123)

                at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:214)

                at javax.naming.InitialContext.lookup(InitialContext.java:392) [classes.jar:1.6.0_51]

                at org.hibernate.cache.infinispan.JndiInfinispanRegionFactory.locateCacheManager(JndiInfinispanRegionFactory.java:71) [hibernate-infinispan-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.cache.infinispan.JndiInfinispanRegionFactory.createCacheManager(JndiInfinispanRegionFactory.java:64) [hibernate-infinispan-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.cache.infinispan.InfinispanRegionFactory.start(InfinispanRegionFactory.java:275) [hibernate-infinispan-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:271) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

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

                at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]

                at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]

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

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

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) [classes.jar:1.6.0_51]

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) [classes.jar:1.6.0_51]

                at java.lang.Thread.run(Thread.java:680) [classes.jar:1.6.0_51]

       

       

      12:03:30,481 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-14) MSC00001: Failed to start service jboss.persistenceunit."appEar.ear#app": org.jboss.msc.service.StartException in service jboss.persistenceunit."appEar.ear#app": Failed to start service

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) [classes.jar:1.6.0_51]

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) [classes.jar:1.6.0_51]

                at java.lang.Thread.run(Thread.java:680) [classes.jar:1.6.0_51]

      Caused by: javax.persistence.PersistenceException: [PersistenceUnit: app] Unable to build EntityManagerFactory

                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)

                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889)

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

                at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162)

                at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85)

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                ... 3 more

      Caused by: org.hibernate.cache.CacheException: Unable to retrieve CacheManager from JNDI [java:jboss/infinispan/hibernate]

                at org.hibernate.cache.infinispan.JndiInfinispanRegionFactory.locateCacheManager(JndiInfinispanRegionFactory.java:75)

                at org.hibernate.cache.infinispan.JndiInfinispanRegionFactory.createCacheManager(JndiInfinispanRegionFactory.java:64)

                at org.hibernate.cache.infinispan.InfinispanRegionFactory.start(InfinispanRegionFactory.java:275)

                at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:271)

                at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737)

                at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)

                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)

                ... 9 more

       

       

      Haven't been able to find how to resolve this one. Any help would be greatly appreciated.

       

      Richard

        • 1. Re: Moving from 4.2.2 to AS 7
          Richard Doust Newbie

          I found another post somewhere that suggested that the persistence.xml should include:

           

                  <property name="hibernate.cache.use_second_level_cache" value="true" />                   

                  <property name="hibernate.cache.use_query_cache" value="true" />


          and implied that if it looked like that, other things would be taken care of automatically, so I changed my persistence.xml:

           

                <shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>

                <properties>

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

                  <property name="hibernate.cache.use_second_level_cache" value="true" />                   

                  <property name="hibernate.cache.use_query_cache" value="true" />

                </properties>


          and got further. I'm no longer having the exception looking up the CacheManager via JNDI. If I'm interpreting the output correctly, I'm actually successful processing the first hbm.xml file, but I appear to be getting an exception on the 2nd one:

           

          14:03:09,466 INFO  [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-10) ISPN000128: Infinispan version: Infinispan 'Brahma' 5.1.2.FINAL

          14:03:09,592 INFO  [org.infinispan.jmx.CacheJmxRegistration] (MSC service thread 1-10) ISPN000031: MBeans were successfully registered to the platform mbean server.

          14:03:09,595 INFO  [org.jboss.as.clustering.infinispan] (MSC service thread 1-10) JBAS010281: Started appEar.ear#app.com.app.hbm.model.BusinessEntity cache from hibernate container

          14:03:09,623 INFO  [org.infinispan.jmx.CacheJmxRegistration] (MSC service thread 1-10) ISPN000031: MBeans were successfully registered to the platform mbean server.

          14:03:09,623 INFO  [org.jboss.as.clustering.infinispan] (MSC service thread 1-10) JBAS010281: Started appEar.ear#app.com.app.session.common.Credit cache from hibernate container

          14:03:09,625 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-10) MSC00001: Failed to start service jboss.persistenceunit."appEar.ear#app": org.jboss.msc.service.StartException in service jboss.persistenceunit."appEar.ear#app": Failed to start service

                    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) [classes.jar:1.6.0_51]

                    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) [classes.jar:1.6.0_51]

                    at java.lang.Thread.run(Thread.java:680) [classes.jar:1.6.0_51]

          Caused by: javax.persistence.PersistenceException: [PersistenceUnit: nym] Unable to build EntityManagerFactory

                    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)

                    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889)

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

                    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162)

                    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85)

                    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                    ... 3 more

          Caused by: org.hibernate.cache.CacheException: Unsupported access type [read-write]

                    at org.hibernate.cache.infinispan.entity.EntityRegionImpl.buildAccessStrategy(EntityRegionImpl.java:33)

                    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:340)

                    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737)

                    at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)

                    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)

                    ... 9 more

           

          Looks like BusinessEntity succeeded, but Credit caused an exception. Unsupported access type. I don't know what that's about or how to find out. Can anyone help with this?

           

          Thanks,

           

          Richard

          • 2. Re: Moving from 4.2.2 to AS 7
            Richard Doust Newbie

            Well, it appears that I had been using the "cache" element from the hbm.xml file in some cases, specifying whether read-write was supported in the cache. I don't remember having done this, but I must have. I am now able to get the ear to deploy after removing the cache element from each of the 5 or so descriptors where I had specified it.