3

I'm trying to switch from ehcache which seems to be working well to 'native' Wildfly's Infinispan. I did not made any change to default configuration of WildFly and I'm using hibernate and infinispan built-in modules. I started with basic persistence configuration like:

    <persistence-unit name="frmwrkjta" transaction-type="JTA">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <jta-data-source>java:jboss/ds/frmwrkmysqljta</jta-data-source>

      <shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode><!-- ALL, NONE, ENABLE_SELECTIVE,DISABLE_SELECTIVE, UNSPECIFIED -->
      <properties>
         <property name="shared-cache-mode" value="ENABLE_SELECTIVE" /> 
<!--         <property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.ehcache.EhCacheRegionFactory"/> -->
         <property name="net.sf.ehcache.configurationResourceName" value="META-INF/ehcache-persistence.xml" />
         <property name="hibernate.cache.use_query_cache" value="true" />
         <property name="hibernate.cache.use_second_level_cache" value="true" />
         <property name="hibernate.generate_statistics" value="true" />
         <property name="hibernate.cache.infinispan.statistics" value="true" />
         <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
<!--          <property name="hibernate.hbm2ddl.auto" value="update" /> -->
         <property name="hibernate.hbm2ddl.auto" value="validate" />
         <property name="hibernate.show_sql" value="true" />
         <property name="org.hibernate.envers.audit_table_suffix" value="_log" />
         <property name="org.hibernate.envers.revision_field_name" value="dbrevision_r" />
         <property name="org.hibernate.envers.revision_type_field_name" value="dbrevtype" />
      </properties>
    </persistence-unit>

Later on I was trying to add properties googled...

  • This first one was my favorit:

         <property name="hibernate.cache.default_cache_concurrency_strategy" value="read-only"/>
    

afterwards also using all optional values like transactional, read-only, nontrict read-write, even read-write ;)

  • then:

         <property name="hibernate.cache.infinispan.container" value="hibernate"/>
    
  • later:

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

All this finished with failed deployment exception:

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

I am using only JPA's @Cacheable annotation in entities...

What am I missing, what am I doing wrong?

EDIT:

Not sure if it matters. I'm adding omitted start of persistence.xml... I'm trying to use JPA2.1:

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd" version="2.1">
mirec
  • 627
  • 1
  • 8
  • 23

1 Answers1

3

Infinispan Hibernate 2LC only supports read-only and transactional strategies. We have plans to add read-write and non-strict-read-write but we have not done so yet.

There should be no need to add either hibernate.cache.infinispan.container nor hibernate.cache.region.factory_class properties.

I would suggest that you start with a simple configuration like this:

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
<persistence-unit name="frmwrkjta">
   <description>example of enabling the second level cache.</description>
   <jta-data-source>java:jboss/ds/frmwrkmysqljta</jta-data-source>
   <shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
   <properties>
      <property name="hibernate.cache.use_second_level_cache" value="true"/>
   </properties>
</persistence-unit>
</persistence> 

And then add properties as you need them, e.g. enable query cache if you need to...etc

Galder Zamarreño
  • 5,027
  • 2
  • 26
  • 34
  • Hi Galder, thank you for your response... I reduced persistence.xml to this simpliest possible(means exactly the same as you suggested) with same result... `org.hibernate.cache.CacheException: Unsupported access type [read-write]` – mirec Feb 25 '15 at 17:45
  • How can I change read-write to anything else? I didn't configure anything like that, why is it trying to use it as default? Even when I set `` – mirec Mar 04 '15 at 12:46
  • 1
    Are you using any annotations? Maybe they are defining the cache concurrency strategy. Either that, or some hardcoding inside the code or other configuration file that's being imported by mistake? Run your app through a debugger and see where that's coming from? – Galder Zamarreño Mar 10 '15 at 08:45
  • I am using only JPA's @javax.persistence.Cacheable without anything else, which is not changing concurrency strategy AFAIK – mirec May 03 '15 at 12:18
  • Hmmmm, just hook the remote debugger from your IDE to see why that happens. It's odd... – Galder Zamarreño May 07 '15 at 16:51