[Logo] Terracotta Discussion Forums (LEGACY READ-ONLY ARCHIVE)
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
ClassCastException when calling SecondLevelCacheStatistics.getEntries() under ehCache + Terracotta  XML
Forum Index -> Ehcache
Author Message
laowai

neo

Joined: 10/02/2009 12:49:36
Messages: 5
Offline

I am trying to inspect the second level cache by calling

Code:
session.getSessionFactory().getStatistics().getSecondLevelCacheStatistics("regionName").getEntries()


and I get

Code:
java.lang.ClassCastException: java.lang.String cannot be cast to org.hibernate.cache.CacheKey
 	at org.hibernate.stat.SecondLevelCacheStatistics.getEntries(SecondLevelCacheStatistics.java:74)


I don't get this if I do not specify <terracotta clustered="true"/> in ehcache.xml for this region. It looks like the key is some kind of terracotta specific value and not the CacheKey object hibernate expects.

Edit: I am using ehcache-core 1.7.2 and ehcache-terracotta 1.8.0
cdennis

master

Joined: 01/19/2009 10:03:26
Messages: 89
Offline

There are two bugs that may be causing this problem:

1. If you are running Ehcache express (i.e. without a custom boot jar) then your cache is running in serialization mode. This means that before Terracotta stores your values on the server it is converting them into a detached form. This is done for both keys and values, values are simply serialized into byte arrays, and keys are serialized and then converted into Strings. Currently the clustered Ehcache instance underlying the Hibernate cache is not converting these keys back into their original form when Ehcache.getKeys() is called (via Region.toMap()). There is already an existing JIRA item tracking this bug (https://jira.terracotta.org/jira/browse/CDV-1444).

2. If you are running in full blown DSO mode then it also possible that you are using an identity cache to back your Hibernate cache. In 1.7.2 there was a bug whereby even identity caches were detaching their keys before storing them in Terracotta (https://jira.terracotta.org/jira/browse/CDV-1445). This is now fixed. However I would strongly recommend you to not use an identity cache with Hibernate - this will in fact be impossible in the upcoming "Darwin" release.

Hope this clears things up for you,

Chris

Chris Dennis (Terracotta Engineer)
laowai

neo

Joined: 10/02/2009 12:49:36
Messages: 5
Offline

Thanks for the pointer; as I am using the express config it looks like CDV-1444 is the issue. Glad to see it's tracked.
 
Forum Index -> Ehcache
Go to:   
Powered by JForum 2.1.7 © JForum Team