1 Reply Latest reply on Feb 21, 2013 5:16 AM by aogier

    NONSTRICT_READ_WRITE not supported on JBoss 7.1.3.Final ?

    aogier

      I obtain "{noformat}org.hibernate.cache.CacheException: Unsupported access type [nonstrict-read-write]{noformat}" when I try to use {noformat}@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE){noformat}

       

       

       

      Here is my Entity to be cached :

       

      {code}

      //...

      import javax.persistence.Cacheable;

      import org.hibernate.annotations.Cache;

      import org.hibernate.annotations.CacheConcurrencyStrategy;

      //...

      @Cacheable(true)

      @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)

      public class MyEntity implements Serializable {

      //...

      }

      {code}

       

      Here is my {noformat}persistence.xml{noformat} (based on what's written on [JBoss 7 JPA Reference Guide|https://docs.jboss.org/author/display/AS71/JPA+Reference+Guide#JPAReferenceGuide-UsingtheInfinispansecondlevelcache]) :

      {code:xml}

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

      <!-- Persistence deployment descriptor for dev profilee -->

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

                version="2.0">

       

                <persistence-unit name="mywebapp">

                          <provider>org.hibernate.ejb.HibernatePersistence</provider>

                          <jta-data-source>java:/mywebappDS</jta-data-source>

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

                          <properties>

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

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

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

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

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

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

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

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

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

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

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

       

                                    <property name="hibernate.cache.region.factory_class" value="org.jboss.as.jpa.hibernate4.infinispan.InfinispanRegionFactory" />

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

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

                          </properties>

                </persistence-unit>

      </persistence>

      {code}

       

      And here is the full stack trace :

       

      {noformat}
      17:20:14,949 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 50) JBAS010281: Cache mywebapp-web.war#mywebapp.com.mycompany.mywebapp.model.MyEntity démarré depuis le conteneur hibernate

      17:20:14,950 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 50) MSC00001: Failed to start service jboss.persistenceunit."mywebapp-web.war#mywebapp": org.jboss.msc.service.StartException in service jboss.persistenceunit."mywebapp-web.war#mywebapp": javax.persistence.PersistenceException: [PersistenceUnit: mywebapp] Unable to build EntityManagerFactory

        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:100) [jboss-as-jpa-7.1.3.Final.jar:7.1.3.Final]

        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146) [rt.jar:1.6.0_27]

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.6.0_27]

        at java.lang.Thread.run(Thread.java:679) [rt.jar:1.6.0_27]

        at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.0.0.GA.jar:2.0.0.GA]

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

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

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

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

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

        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$500(PersistenceUnitServiceImpl.java:57) [jboss-as-jpa-7.1.3.Final.jar:7.1.3.Final]

        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:96) [jboss-as-jpa-7.1.3.Final.jar:7.1.3.Final]

        ... 4 more

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

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

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

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

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

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

        ... 9 more

      {noformat}

       

       

      Any idea if I've done something wrong ? Or is there any CacheConcurrencyStrategy which can't be used with second level cache of JBoss 7 ?