-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Using EhCache for both Hibernate and another application
PostPosted: Mon Sep 19, 2011 10:09 pm 
Newbie

Joined: Mon Sep 19, 2011 10:00 pm
Posts: 1
We are using EhCache both for Hibernate and within our applications and we were having some issues relating to multipleCacheManager threads as some of the code was using :

new CacheManager ()

rather than say

CacheManager.getInstance (which if used everywhere only uses the one CacheManager instance which sounds prefereable).

In order to resolve this I changed all the new CacheManager() code to :

CacheManager.getInstance which resolved the cachemanager thread issue but it caused the following error:

Cache is not alive error to be thrown by net.sf.ehcache.Cache in the checkStatus method.

After some debugging it appears that org.hibernate.impl.SessionFactoryImpl is calling the stop method in the class referenced by the hibernate.cache.provider_class implementation on startup of the Weblogic application server (which is weird in itself). The default implementation for this class is org.hibernate.cache.EhCacheProvider which within the stop method destoys the CacheManager instance (presumably on the basis that Hibernate is the only product using the CacheManager). This in turn is removing the CacheManager instance that is pointing to all of the application Caches outside of Hibernate.

This issue seems to be referenced in a couple of posts but I am looking for the best practice approach to get around this issue.

The way that I have got around this so far is tailoring the EhCacheProvider code so that it does not remove the CacheManager singleton in the stop method but I am concerned about what other implications this may have.

As stated I already have a solution so I really only need confirmation that this is a suitable solution or another Best Practice way of getting around this issue.

We are using the following versions: EhCache (1.7.2) and Hibernate 3.0


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.