ReadOnlyException with Hibernate + EHcache TIM
----------------------------------------------

                 Key: CDV-840
                 URL: https://jira.terracotta.org/jira//browse/CDV-840
             Project: Community Development
          Issue Type: Bug
          Components: Integration Modules
    Affects Versions: 2.6.2
            Reporter: Kunal Bhasin
            Assignee: Issue Review Board


We are testing TC for Hibernate 3.2.5 using ehcache 1.3 within Tomcat 6 under 
Linux.

We can see objects in the cache using the TC console roots. As we navigate the 
webapp, we can see new objects entering the distributed cache.

However, queries that have setCacheable(true) receive an exception:

com.tc.object.util.ReadOnlyException:
*******************************************************************************
Attempt to write to a shared object inside the scope of a lock declared as a
read lock. All writes to shared objects must be within the scope of one or
more shared locks with write access defined in your Terracotta configuration.

Please alter the locks section of your Terracotta configuration so that this
access is auto-locked or protected by a named lock with write access.

For more information on this issue, please visit our Troubleshooting Guide at:
http://terracotta.org/kit/troubleshooting

Caused by Thread: TP-Processor9 in VM(2)
Failed To Modify Field: org.hibernate.type.EntityType.returnedClass in 
org.hibernate.type.EntityType
*******************************************************************************

at 
com.tc.object.tx.ClientTransactionManagerImpl.makeReadOnlyException(ClientTransactionManagerImpl.java:765)
at 
com.tc.object.tx.ClientTransactionManagerImpl.fieldChanged(ClientTransactionManagerImpl.java:607)
at com.tc.object.TCObjectImpl.objectFieldChanged(TCObjectImpl.java:297)
at org.hibernate.type.EntityType.__tc_setreturnedClass(EntityType.java)
at org.hibernate.type.EntityType.getReturnedClass(EntityType.java:174)
at org.hibernate.cache.QueryKey.equals(QueryKey.java:65)
at java.util.HashMap.getEntry(HashMap.java:349)
at java.util.HashMap.__tc_getEntryUnderResolvedLock(HashMap.java)
at java.util.HashMap.get(HashMap.java)
at 
com.tcclient.cache.CacheDataStore.findCacheDataUnlocked(CacheDataStore.java:330)
at com.tcclient.cache.CacheDataStore.get(CacheDataStore.java:183)
at com.tcclient.ehcache.TimeExpiryMap.get(TimeExpiryMap.java:106)
at net.sf.ehcache.store.MemoryStore.get(MemoryStore.java:130)
at net.sf.ehcache.Cache.searchInMemoryStore(CacheTC.java:871)
at net.sf.ehcache.Cache.get(CacheTC.java:734)
at net.sf.ehcache.hibernate.EhCache.get(EhCache.java:82)
at org.hibernate.cache.StandardQueryCache.get(StandardQueryCache.java:105)
at org.hibernate.loader.Loader.getResultFromQueryCache(Loader.java:2161)
at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2126)
at org.hibernate.loader.Loader.list(Loader.java:2096)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:305)


The exceptions go away if we setCacheable(false).

Our TIMs are:
<module name="tim-hibernate-3.2.5" version="1.1.2" />
<module name="tim-ehcache-1.3" version="1.1.2" />
<module name="tim-ehcache-commons" version="1.1.2" />
<module name="tim-cglib-2.1.3" version="1.1.2"/>
<module name="clustered-commons-collections-3.1" version="2.6.2"/>

Our code uses CacheManager.getInstance(), so as per the TC documentation we do 
not specify a root as the TIM is taking care of that for us.

We enabled autolocks for all synchronized methods by using:
<locks>
<autolock>
<lock-level>write</lock-level>
<method-expression>* *..*.*(..)</method-expression>
</autolock>
</locks>
We also tested with the 'locks' section commented out and therefore not 
explicitly setting locks but relying on the TIMs.

Our hibernate cfg enables ehcache for L2 cache and including queries:
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.use_query_cache">true</property>
<property 
name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
<!-- <property 
name="hibernate.cache.provider_class">net.sf.ehcache.hibernate.SingletonEhCacheProvider</property>
-->
Note that we tried both EhCacheProvider and the Singleton

Any hints as to why query caching causes the ReadOnlyException? 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
https://jira.terracotta.org/jira//secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        
_______________________________________________
tc-dev mailing list
tc-dev@lists.terracotta.org
http://lists.terracotta.org/mailman/listinfo/tc-dev

Reply via email to