-->
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: EHCache provider closes the CacheManager
PostPosted: Thu Aug 31, 2006 1:49 am 
Newbie

Joined: Thu Aug 31, 2006 1:29 am
Posts: 1
Using hibernate in combination with something else that uses EHCache gives problems.

The 'something else' in my case is code of my own where I need specific caching (using EHCache).

The problem can be described as follows: EHCache provides a CacheManager, which (in version 1.1) is a singleton. The CacheManager is used to manage caches (creating new caches, constructing previously configured caches, deleting caches, ...). The CacheManager also provides a shutdown method that will dispose all caches managed by the CacheManager. As the CacheManager is a singleton, 'all caches' really means all caches in the running JVM.

Now the problem (I think) is that in hibernate the EhCacheProvider (a hibernate class) calls this shutdown method in its stop method, like this:

public void stop() {
if (manager != null) {
manager.shutdown();
manager = null;
}
}

This causes all caches to be disposed, including the caches that were not created or used by hibernate.

A solution would be to not call the shutdown method on the CacheManager. but to call removeCache(String name) for every cache hibernate actually used.

Hibernate version:

3.1.2

EhCache version:

1.1

Full stack trace of any exception that occurs:

My caches get disposed. so when I try to use them I get stack traces like

(ntc.nms.* is my own code)

java.lang.IllegalStateException: The ntc.nms.pmt.metric.MetricCache@25a649 Cache is not alive.
at net.sf.ehcache.Cache.checkStatus(Cache.java:713)
at net.sf.ehcache.Cache.getSize(Cache.java:655)
at ntc.nms.pmt.metric.MetricCache.size(MetricCache.java:128)
at ntc.nms.pmt.metric.MetricCache.verifyCacheSize(MetricCache.java:321)
at ntc.nms.pmt.metric.MetricCache.addAll(MetricCache.java:209)
at ntc.nms.pmt.monitor.MultiMonitorMetric.deriveMetrics(MultiMonitorMetric.java:215)
at ntc.nms.pmt.monitor.MultiMonitorMetric.recoverMetrics(MultiMonitorMetric.java:186)
at ntc.nms.pmt.monitor.MultiMonitorMetric.scan(MultiMonitorMetric.java:109)
at ntc.nms.framework.performance.Scanner$1.run(Scanner.java:104)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)


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.