14 Replies Latest reply on Jan 26, 2012 10:22 PM by Brent Douglas

    Setting up Infinispan as Hibernate Level 2 cache problem

    lindsaybraine Newbie

      Hopeing someone can help - and I am not sure I shoudl not be posting this on the Infinispan discussion group....

       

      I am using JBoss 7.1 CR1.

      I want to use Inifinispan as the second level cache.

      I am using JPA (backed by Hibernate)

       

      I followed the execellant article at : https://docs.jboss.org/author/display/ISPN/Using+Infinispan+as+JPA-Hibernate+Second+Level+Cache+Provider

       

      I have declared in my EAR's persistence.xml file the following :

       

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

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

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

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

                  <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.CMTTransactionFactory"/>

                  <property name="hibernate.transaction.manager_lookup_class"   value="org.hibernate.transaction.JBossTransactionManagerLookup"/>

       

      but on starting and ny EAR being deployed I get this error :

       

      ERROR (MSC service thread 1-1) 2011-12-23 18:59:37,893 [org.jboss.msc.service.fail] ServiceLogger_$logger MSC00001: Failed to start service jboss.persistenceuni

      t."apollo.ear#ApolloPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."apollo.ear#ApolloPU": Failed to start service

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

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

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

              at java.lang.Thread.run(Thread.java:662) [:1.6.0_24]

      Caused by: java.lang.NoClassDefFoundError: javax/naming/NamingException

              at java.lang.Class.getDeclaredConstructors0(Native Method) [:1.6.0_24]

              at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389) [:1.6.0_24]

              at java.lang.Class.getConstructor0(Class.java:2699) [:1.6.0_24]

              at java.lang.Class.getConstructor(Class.java:1657) [:1.6.0_24]

              at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:383)

              at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:248)

              at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2270)

              at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2266)

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

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

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

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

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

              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:1.0.1.GA]

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

              ... 3 more

      Caused by: java.lang.ClassNotFoundException: javax.naming.NamingException from [Module "org.hibernate.infinispan:main" from local module loader @16e1fb1 (roots:

      D:\dpa-platform\services\modules)]

              at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)

              at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)

              at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)

              at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)

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

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

              ... 20 more

       

      This all looked vaguely classloader / module visibility like - so I added into the EAR manifest.mf file the two highlighted entries :

       

      Dependencies: org.apache.log4j, org.slf4j, org.hibernate, org.hibernate.infinispan

       

       

      But no joy. The stack trace seems to suggest that it is when loading up the regionfactory that the class not found error occurs (and I have checked  - the decalred class is there in the JAR file in the org.hibernate.infinispan module).

       

      SO, what am I missing !!!!

        • 1. Re: Setting up Infinispan as Hibernate Level 2 cache problem
          lindsaybraine Newbie

          small update: double checking the hibernate propeties against what was in the JAR files revealed:

           

          <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.CMTTransactionFactory"/>

           

          CMTTransactionFactory does not exist - si I have removed the property for the time being

           

          <property name="hibernate.transaction.manager_lookup_class"   value="org.hibernate.transaction.JBossTransactionManagerLookup"/>

           

          There was only one class available in org.hobernate.transaction - so I modified the parameter to read :

           

          <property name="hibernate.transaction.manager_lookup_class"   value="org.hibernate.transaction.TransactionManagerLookup"/>

           

          But still the same stack trace is seen

          • 2. Re: Setting up Infinispan as Hibernate Level 2 cache problem
            Scott Marlow Master

            Could you try setting fewer properties.  The defaults will handle the rest (we are still tuning them but the following should work). 

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

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

             

            As you can see in the Hibernate 4 integration code, the transaction manager integration is already specified and the other second level cache related properties are set for you (if "hibernate.cache.use_second_level_cache" is true).

             

            You can override the defaults but it might be easier to try the above settings before doing so.

             

            Scott

            • 3. Re: Setting up Infinispan as Hibernate Level 2 cache problem
              lindsaybraine Newbie

              Scott.

               

              Apologies for the delay in this response - all down to the Christmas break.

               

              I updated the persistence.xml file to read :

               

                       <properties>

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

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

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

               

              On starting JBoss AS7 the console output stopped at :

               

              INFO  (MSC service thread 1-1) 2011-12-28 13:06:21,640 [org.jboss.weld] WeldDeploymentProcessor Starting Services for CDI deployment: apollo.ear

              INFO  (MSC service thread 1-1) 2011-12-28 13:06:21,686 [org.jboss.weld.Version] WeldBootstrap WELD-000900 1.1.4 (Final)

               

              After a minute the output indicated a failure to deploy - a timeout in fact !!

               

              INFO  (DeploymentScanner-threads - 2) 2011-12-28 13:07:15,363 [org.jboss.as.server] DeploymentHandlerUtil$1 JBAS015856: Undeploy of deployment "remotex.rar" was

              rolled back with failure message Operation cancelled

              INFO  (DeploymentScanner-threads - 2) 2011-12-28 13:07:15,363 [org.jboss.as.server] DeploymentHandlerUtil$1 JBAS015857: Undeploy of deployment "apollo.ear" was

              rolled back with no failure message

              ERROR (DeploymentScanner-threads - 2) 2011-12-28 13:07:15,394 [org.jboss.as.controller.management-operation] AbstractOperationContext JBAS014612: Operation ("de

              ploy") failed - address: ([("deployment" => "remotex.rar")]): java.util.concurrent.CancellationException: Operation cancelled asynchronously

                      at org.jboss.as.controller.OperationContextImpl.awaitContainerMonitor(OperationContextImpl.java:356) [jboss-as-controller-7.1.0.CR1.jar:7.1.0.CR1]

                      at org.jboss.as.controller.OperationContextImpl.releaseStepLocks(OperationContextImpl.java:599) [jboss-as-controller-7.1.0.CR1.jar:7.1.0.CR1]

               

               

              I went back to the persistence.xml and removed the two additonal lines we added - and Hibernate starts up just fine, but without the infinispan caching :

               

              INFO  (MSC service thread 1-4) 2011-12-28 13:15:32,749 [org.jboss.weld] WeldDeploymentProcessor Starting Services for CDI deployment: apollo.ear

              INFO  (MSC service thread 1-4) 2011-12-28 13:15:32,784 [org.jboss.weld.Version] WeldBootstrap WELD-000900 1.1.4 (Final)

              INFO  (MSC service thread 1-4) 2011-12-28 13:15:32,987 [org.jboss.jpa] PersistenceUnitServiceImpl JBAS011402: Starting Persistence Unit Service 'apollo.ear#ApolloPU'

              INFO  (MSC service thread 1-4) 2011-12-28 13:15:33,449 [org.hibernate.annotations.common.Version] Version HCANN000001: Hibernate Commons Annotations {4.0.1.Final}

              INFO  (MSC service thread 1-4) 2011-12-28 13:15:33,457 [org.hibernate.Version] Version HHH000412: Hibernate Core {4.0.0.Final}

              INFO  (MSC service thread 1-4) 2011-12-28 13:15:33,459 [org.hibernate.cfg.Environment] Environment HHH000206: hibernate.properties not found

              INFO  (MSC service thread 1-4) 2011-12-28 13:15:33,461 [org.hibernate.cfg.Environment] Environment HHH000021: Bytecode provider name :javassist

              INFO  (MSC service thread 1-4) 2011-12-28 13:15:33,519 [org.hibernate.ejb.Ejb3Configuration] Ejb3Configuration HHH000204: Processing PersistenceUnitInfo [

                      name: ApolloPU

                      ...]

              INFO  (MSC service thread 1-4) 2011-12-28 13:15:34,561 [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] ConnectionProviderInitiator

              HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider

              INFO  (MSC service thread 1-4) 2011-12-28 13:15:35,047 [org.hibernate.dialect.Dialect] Dialect HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect

              INFO  (MSC service thread 1-4) 2011-12-28 13:15:35,059 [org.hibernate.engine.jdbc.internal.LobCreatorBuilder] LobCreatorBuilder HHH000424: Disabling contextual

              LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException

              INFO  (MSC service thread 1-4) 2011-12-28 13:15:35,067 [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] TransactionFactoryInitiator HHH00

              0268: Transaction strategy: org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory

              INFO  (MSC service thread 1-4) 2011-12-28 13:15:35,072 [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] ASTQueryTranslatorFactory HHH000397: Using AST

              QueryTranslatorFactory

              INFO  (MSC service thread 1-4) 2011-12-28 13:15:35,106 [org.hibernate.validator.util.Version] Version Hibernate Validator 4.2.0.Final

              INFO  (MSC service thread 1-4) 2011-12-28 13:15:39,097 [org.jboss.weld] WeldService Starting weld service

               

               

              Not sure what to do from here.....

              • 4. Re: Setting up Infinispan as Hibernate Level 2 cache problem
                Scott Marlow Master

                Try enabling TRACE logging in as7/standalone/configuration/standalone.xml (change from INFO to TRACE for everything).  Then look in as7/standalone/log/server.log for any reasons why "rolled back with failure message Operation cancelled" occurred (search for the "rolled back with failure message Operation cancelled" and read back a few lines for anything that might stand out). 

                 

                Not that its related, could you describe how apollo.ear is using remotex.rar (I assume its a connector for some backend but which one)? 

                • 5. Re: Setting up Infinispan as Hibernate Level 2 cache problem
                  lindsaybraine Newbie

                  So - I did two runs - one with INFO level and one with TRACE.

                   

                  The last correspsonding INFO message in both log files was the last highlighted line below (I am showing the INFO log here as the TRACE log is very very verbose and 8M in size)

                   

                  INFO  (MSC service thread 1-2) 2011-12-31 14:44:05,388 [org.jboss.as.server.deployment] AbstractDeploymentUnitService Starting deployment of "remotex.rar"

                  INFO  (MSC service thread 1-3) 2011-12-31 14:44:05,388 [org.jboss.as.server.deployment] AbstractDeploymentUnitService Starting deployment of "apollo.ear"

                  INFO  (MSC service thread 1-4) 2011-12-31 14:44:06,471 [apollo.remotex.spi.RemoteExecutionResourceAdapter] RemoteExecutionResourceAdapter Remote Execution Resource Adapter server port set to 25011

                  INFO  (MSC service thread 1-4) 2011-12-31 14:44:06,552 [apollo.remotex.spi.RemoteExecutionResourceAdapter] RemoteExecutionResourceAdapter Remote Execution Resource Adapter server web port set to 9002

                  INFO  (MSC service thread 1-4) 2011-12-31 14:44:06,596 [apollo.remotex.spi.RemoteExecutionResourceAdapter] RemoteExecutionResourceAdapter Remote Execution Resource Adapter web username set to administrator

                  INFO  (MSC service thread 1-4) 2011-12-31 14:44:06,617 [apollo.remotex.spi.RemoteExecutionResourceAdapter] RemoteExecutionResourceAdapter Remote Execution Resource Adapter web password set to [shhhhh - secret...]

                  INFO  (MSC service thread 1-4) 2011-12-31 14:44:06,637 [apollo.remotex.spi.ManagedRemoteExecutionConnectionFactory] ManagedRemoteExecutionConnectionFactory Create Connection Factory called

                  INFO  (MSC service thread 1-4) 2011-12-31 14:44:06,649 [org.jboss.as.deployment.connector] AbstractResourceAdapterDeploymentService$AbstractAS7RaDeployer JBAS010406: Registered connection factory java:jboss/resourceadapters/remote-execution

                  INFO  (MSC service thread 1-4) 2011-12-31 14:44:06,673 [org.jboss.as.connector.deployers.RaXmlDeployer] AbstractResourceAdapterDeployer IJ020002: Deployed: file:/D:/dpa-platform/services/standalone/tmp/vfs/tempd9fbe2742a10ddd/remotex.rar-f3cd6e221748b193/contents/

                  INFO  (MSC service thread 1-4) 2011-12-31 14:44:06,685 [org.jboss.as.deployment.connector] AbstractResourceAdapterDeploymentService$AbstractAS7RaDeployer$1 JBAS010401: Bound JCA ConnectionFactory [java:jboss/resourceadapters/remote-execution]

                  INFO  (MSC service thread 1-3) 2011-12-31 14:44:07,336 [org.jboss.as.server.deployment] AbstractDeploymentUnitService Starting deployment of "remotex-war-1.0-SNAPSHOT.war"

                  INFO  (MSC service thread 1-3) 2011-12-31 14:44:07,348 [org.jboss.as.server.deployment] AbstractDeploymentUnitService Starting deployment of "services-implementation-1.0-SNAPSHOT.jar"

                  INFO  (MSC service thread 1-3) 2011-12-31 14:44:07,357 [org.jboss.as.server.deployment] AbstractDeploymentUnitService Starting deployment of "apollo-server-startup.jar"

                   

                  Between this line and the line indicating of an operation rollback:

                   

                  INFO  (DeploymentScanner-threads - 2) 2011-12-28 21:50:38,865 [org.jboss.as.server] DeploymentHandlerUtil$1 JBAS015856: Undeploy of deployment "remotex.rar" was rolled back with failure message Operation cancelled

                   

                  there are 1567 lines of predominately TRACE statements, which dont reveal much (lots of of opertions being repeated time and time again!)

                  Within these lines are some DEBUG statements which I have pulled out from the TRACE log:

                   

                  DEBUG (MSC service thread 1-4) 2011-12-28 21:50:32,063 [org.jboss.as.server.deployment.module] ModuleSpecProcessor Creating moduledeployment.remotex.rar:main

                  DEBUG (MSC service thread 1-4) 2011-12-28 21:50:32,079 [org.jboss.as.server.deployment.module] ModuleSpecProcessor Adding resource "/D:/dpa-platform/services/content/remotex.rar" to module deployment.remotex.rar:main

                  DEBUG (MSC service thread 1-4) 2011-12-28 21:50:32,172 [org.jboss.as.server.deployment.module] ModuleSpecProcessor Adding resource "/D:/dpa-platform/services/content/remotex.rar/connector-api-1.5.jar" to module deployment.remotex.rar:main

                  DEBUG (MSC service thread 1-4) 2011-12-28 21:50:32,172 [org.jboss.as.server.deployment.module] ModuleSpecProcessor Adding resource "/D:/dpa-platform/services/content/remotex.rar/stax-1.2.0.jar" to module deployment.remotex.rar:main

                  DEBUG (MSC service thread 1-4) 2011-12-28 21:50:32,172 [org.jboss.as.server.deployment.module] ModuleSpecProcessor Adding resource "/D:/dpa-platform/services/content/remotex.rar/remotex-api-1.0-SNAPSHOT.jar" to module deployment.remotex.rar:main

                  DEBUG (MSC service thread 1-4) 2011-12-28 21:50:32,204 [org.jboss.as.server.deployment.module] ModuleSpecProcessor Adding resource "/D:/dpa-platform/services/content/remotex.rar/commons-beanutils-core-1.8.3.jar" to module deployment.remotex.rar:main

                  DEBUG (MSC service thread 1-4) 2011-12-28 21:50:32,204 [org.jboss.as.server.deployment.module] ModuleSpecProcessor Adding resource "/D:/dpa-platform/services/content/remotex.rar/xpp3-1.1.3.3.jar" to module deployment.remotex.rar:main

                  DEBUG (MSC service thread 1-4) 2011-12-28 21:50:32,204 [org.jboss.as.server.deployment.module] ModuleSpecProcessor Adding resource "/D:/dpa-platform/services/content/remotex.rar/common-1.0-SNAPSHOT.jar" to module deployment.remotex.rar:main

                  DEBUG (MSC service thread 1-4) 2011-12-28 21:50:32,219 [org.jboss.as.server.deployment.module] ModuleSpecProcessor Adding resource "/D:/dpa-platform/services/content/remotex.rar/simple-xml-2.5.3.jar" to module deployment.remotex.rar:main

                  ...

                  ... bundled JAR and Module resolutions repeated

                  ...

                  DEBUG (MSC service thread 1-2) 2011-12-28 21:50:32,890 [org.jboss.modules] ModuleLoader Module deployment.remotex.rar:main defined by Service Module Loader

                  INFO  (DeploymentScanner-threads - 2) 2011-12-28 21:50:38,865 [org.jboss.as.server] DeploymentHandlerUtil$1 JBAS015856: Undeploy of deployment "remotex.rar" was rolled back with failure message Operation cancelled

                  DEBUG (MSC service thread 1-2) 2011-12-28 21:50:40,440 [org.jboss.as.deployment.connector] ResourceAdapterDeploymentService DEPLOYMENT name = remotex

                  DEBUG (MSC service thread 1-2) 2011-12-28 21:50:41,423 [org.jboss.as.connector.deployers.RADeployer] AbstractResourceAdapterDeployer No activation: apollo.remotex.spi.ManagedRemoteExecutionConnectionFactory

                  DEBUG (MSC service thread 1-2) 2011-12-28 21:50:41,423 [org.jboss.as.deployment.connector] AbstractResourceAdapterDeploymentService$AbstractAS7RaDeployer Registering ResourceAdapter remotex

                  DEBUG (MSC service thread 1-2) 2011-12-28 21:50:41,439 [org.jboss.as.connector.deployers.RADeployer] AbstractResourceAdapterDeployer Activated: file:/D:/dpa-platform/services/standalone/tmp/vfs/tempbeb3db0d8ea425ea/remotex.rar-57bcfd623af217bd/contents/

                  DEBUG (MSC service thread 1-1) 2011-12-28 21:50:41,454 [org.jboss.as.deployment.connector] ResourceAdapterDeploymentService Stopping sevice service jboss.ra.deployment.remotex

                  DEBUG (MSC service thread 1-1) 2011-12-28 21:50:41,454 [org.jboss.as.deployment.connector] AbstractResourceAdapterDeploymentService Undeploying: remotex

                  DEBUG (MSC service thread 1-4) 2011-12-28 21:50:41,954 [org.jboss.as.security.service.JaccService] JaccService Cannot create permissions with 'null' metaData for id=remotex.rar

                   

                  The only other 'error' I can see in the log file after this is :

                   

                  DEBUG (Periodic Recovery) 2011-12-28 21:51:55,724 [org.jboss.jca.core.recovery.DefaultRecoveryPlugin] DefaultRecoveryPlugin Error during connection close(): java.lang.NoSuchMethodException: org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6.close(null)

                            at java.lang.Class.getMethod(Class.java:1605) [:1.6.0_24]

                            at org.jboss.jca.core.recovery.DefaultRecoveryPlugin.close(DefaultRecoveryPlugin.java:105)

                            at org.jboss.jca.core.tx.jbossts.XAResourceRecoveryImpl.closeConnection(XAResourceRecoveryImpl.java:411)

                            at org.jboss.jca.core.tx.jbossts.XAResourceRecoveryImpl.getXAResources(XAResourceRecoveryImpl.java:176)

                            at com.arjuna.ats.internal.jbossatx.jta.XAResourceRecoveryHelperWrapper.getXAResources(XAResourceRecoveryHelperWrapper.java:51) [jbossjts-integration-4.16.0.Final.jar:]

                            at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.resourceInitiatedRecoveryForRecoveryHelpers(XARecoveryModule.java:462) [jbossjts-4.16.0.Final.jar:]

                            at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.bottomUpRecovery(XARecoveryModule.java:385) [jbossjts-4.16.0.Final.jar:]

                            at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.periodicWorkSecondPass(XARecoveryModule.java:166) [jbossjts-4.16.0.Final.jar:]

                            at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.doWorkInternal(PeriodicRecovery.java:789) [jbossjts-4.16.0.Final.jar:]

                            at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.run(PeriodicRecovery.java:371) [jbossjts-4.16.0.Final.jar:]

                   

                  but this looks unconnected.

                   

                  To your late question - Apollo.ear contains logic that instructs Remotex to go off and do something with remote services. Remotex is responsible for the control, access and state of that communication. Apollo.ear is all business logic, communicating (instructing) Remotex via MDB. Communication between the two is asynchronous.

                   

                  So it looks like something to do with Remotex.rar not deploying correctly with Level 2 cache enabled, if I am reading this right.

                  • 6. Re: Setting up Infinispan as Hibernate Level 2 cache problem
                    Markus Dahm Novice

                    Hi,

                     

                    I've got a similar issue where my 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="devA-PU" transaction-type="JTA">

                        <!-- Important: no java:/, just a relative path !! -->

                        <jta-data-source>java:jboss/datasources/Meyle-devA-DS</jta-data-source>

                     

                        <!-- TODO: Cache konfigurieren -->

                        <!-- ALL: force caching for all entities -->

                        <!-- NONE: disable caching for all entities (useful to take second-level cache out of the equation) -->

                        <!-- ENABLE_SELECTIVE (default): enable caching when explicitly marked with @Cacheable -->

                        <!-- DISABLE_SELECTIVE: enable caching unless explicitly marked as @Cacheable(false) (not recommended) -->

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

                     

                        <!-- AUTO: if Bean Validation is present in the classpath, CALLBACK and DDL are activated. -->

                        <!-- CALLBACK: entities are validated on creation, update and deletion. If no Bean Validation provider is present, an

                          exception is raised at initialization time. -->

                        <!-- DDL: (not standard, see below) database schemas are entities are validated on creation, update and deletion. If

                          no Bean Validation provider is present, an exception is raised at initialization time. -->

                        <!-- NONE: Bean Validation is not used at all -->

                     

                        <!-- <validation-mode>CALLBACK</validation-mode> -->

                     

                        <properties>

                          <!-- Properties for Hibernate (default provider for JBoss AS) -->

                          <!-- Do NOT work with Hibernate, when the schema is empty !!!! BUG -->

                          <property name="hibernate.default_schema" value="${hibernate.default_schema}" />

                     

                          <property name="hibernate.dialect" value="${hibernate.dialect}" />

                     

                          <property name="hibernate.hbm2ddl.auto" value="${hibernate.hbm2ddl.auto}" />

                          <!--

                          <property name="hibernate.show_sql" value="${hibernate.show_sql}" />

                          <property name="hibernate.format_sql" value="${hibernate.format_sql}" />

                           -->

                     

                          <!-- Infinispan cache configuration -->

                          <!-- https://docs.jboss.org/author/pages/viewpage.action?pageId=4784208#HowdoImigratemyapplicationfromAS5orAS6toAS7-InfinispanReplacementforJPA%2FHibernateSecondLevelCache -->

                          <!-- https://docs.jboss.org/author/display/ISPN/Using+Infinispan+as+JPA-Hibernate+Second+Level+Cache+Provider -->

                     

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

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

                          <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" />

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

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

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

                     

                          <!-- Enable batching -->

                          <property name="hibernate.jdbc.batch_size" value="20" />

                          <property name="hibernate.default_batch_fetch_size" value="8" />

                        </properties>

                      </persistence-unit>

                    </persistence>

                     

                    The error I get is similarly funny:

                     

                    2012.01.02 12:20:11 ERROR [org.jboss.msc.service.fail] MSC00001: Failed to start service jboss.persistenceunit."devA.war#devA-PU": org.jboss.msc.service.StartException in service jboss.persistenceunit."devA.war#devA-PU": Failed to start service
                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1780) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
                        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: devA-PU] Unable to build EntityManagerFactory
                        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
                        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890)
                        at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
                        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:1.0.1.GA]
                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
                        ... 3 more
                    Caused by: org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.infinispan.JndiInfinispanRegionFactory]
                        at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:400)
                        at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:248)
                        at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2270)
                        at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2266)
                        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1735)
                        at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:76)
                        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905)
                        ... 9 more
                    Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class [org.hibernate.cache.infinispan.JndiInfinispanRegionFactory]
                        at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:141)
                        at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:383)
                        ... 15 more
                    Caused by: java.lang.ClassNotFoundException: Could not load requested class : org.hibernate.cache.infinispan.JndiInfinispanRegionFactory
                        at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl$1.findClass(ClassLoaderServiceImpl.java:99)
                        at java.lang.ClassLoader.loadClass(ClassLoader.java:306) [:1.6.0_26]
                        at java.lang.ClassLoader.loadClass(ClassLoader.java:247) [:1.6.0_26]
                        at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:138)
                        ... 16 more
                    

                     

                    The module exists (I checked the JAR), but there is a ClassNotFoundException ????

                     

                    Cheers

                      Markus

                    • 7. Re: Setting up Infinispan as Hibernate Level 2 cache problem
                      Brent Douglas Newbie

                      Hi Markus,

                       

                      What happens when you remove:

                       

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

                       

                      from persistence.xml and use the default region factory ("org.jboss.as.jpa.hibernate.cache.infinispan.InfinispanRegionFactory")?

                       

                      Brent

                      • 8. Re: Setting up Infinispan as Hibernate Level 2 cache problem
                        Markus Dahm Novice

                        Hi,

                         

                        now I just have a

                         

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

                         

                        which seems to work out of the box! At least since version 7.0.2, the configuration was necessary in earlier versions.

                         

                        I see some statements in the server log like

                         

                        2012.01.03 15:16:21 INFO  [org.infinispan.factories.ComponentRegistry] ISPN000128: Infinispan version: Infinispan 'Pagoa' 5.0.1.FINAL
                        2012.01.03 15:16:21 INFO  [org.jboss.as.clustering.infinispan.subsystem] Started devA.war#devA-PU.com.meyle.deva.model.Zubehoer cache from hibernate container
                        2012.01.03 15:16:21 WARN  [org.infinispan.manager.DefaultCacheManager] ISPN000156: You are not starting all your caches at the same time. This can lead to problems as asymmetric clusters are not supported, see ISPN-658. We recommend using EmbeddedCacheManager.startCaches() to start all your caches upfront.
                        

                         

                        Although the last statement makes me nervous we've got no problems yet.

                         

                        Cheers

                          Markus

                        • 9. Re: Setting up Infinispan as Hibernate Level 2 cache problem
                          Radoslav Husar Master

                          Hi Markus,

                           

                          there is nothing to worry about, the message has already disappeared in 7.1.x releases as assymetric clusters are supported.

                           

                          You can check https://issues.jboss.org/browse/ISPN-658

                           

                          No worries there.

                           

                          HTH,

                          Rado

                          • 10. Re: Setting up Infinispan as Hibernate Level 2 cache problem
                            Scott Marlow Master

                            Lindsay,

                             

                            Someone pointed out your other post to me, did that have any impact on this issue?  I'm not yet sure of the cause yet.

                             

                            Scott

                            • 11. Re: Setting up Infinispan as Hibernate Level 2 cache problem
                              lindsaybraine Newbie

                              Scott

                               

                              Thanks for reaching out again.

                               

                              Unfortunately the upgrade to AS 7.1 CR1b did not solve this problem (although it did solve the RAR issues I had).

                               

                              Going back through AS7 threads I came across this  :http://community.jboss.org/thread/176347

                               

                              And the description of what was seen seems to fit. A JIRA has been raised : AS7-3080 which I can see you are involved with. I am watching the progress and discussion on to see how things get resolved.

                               

                              We are in the process of migrating our App to AS7 - and expect to be finished with clean buuld coming off Jenkin in the next week. The attempt to use Infinispan as Hibernate Cache was an R&D event, and not critical to the application. I had hopped to do some benchmarking comparing transactions with it switched on or off.

                               

                              If you need another real world test bed for AS7-3080 resolution - just shout.

                               

                              If you think this issue I had is unrelated, let me know and I will keep digging.

                               

                              Happy New Year !

                              • 12. Re: Setting up Infinispan as Hibernate Level 2 cache problem
                                Brent Douglas Newbie

                                Lindsay,

                                 

                                If you're keen to build AS7 rather than use a release you can try building from https://github.com/BrentDouglas/jboss-as/tree/AS7-3080. I develop on a build of that.

                                 

                                Brent

                                • 13. Re: Setting up Infinispan as Hibernate Level 2 cache problem
                                  lindsaybraine Newbie

                                  Brent

                                   

                                  Thanks. I am returning to this issue after some time away and will post updated.

                                   

                                  Regards

                                  • 14. Re: Setting up Infinispan as Hibernate Level 2 cache problem
                                    Brent Douglas Newbie

                                    Lindsay,

                                     

                                    I've changed that branch a bit since the that reply. Currently adds a new region factory for hibernate3 deployments that mirror's the hibernate4 default region factory. I'm not certain but I think that you might need this to use clustering. Running on that branch you can use the default region factory so delete these lines from persistence.xml and you should be good to go.

                                     

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

                                     

                                    If you just want to use the second level cache you should be able to run it straight from the master branch now (as of this afternoon) using JndiRegionFactory. In your standalone.xml change the line:

                                     

                                    <cache-container name="hibernate" default-cache="local-query">
                                    

                                     

                                    to

                                     

                                    <cache-container name="hibernate" default-cache="local-query" jndi-name="java:jboss/infinispan/hibernate" start="EAGER">
                                    

                                     

                                    and you should be right.

                                     

                                    Brent