Question

I am working on a project whose most of the Junit are failing. My job is to fix them and make them run. I have fixed around 200 Junit classes but there are around 136 Junits still failing, reason no Idea, some times they get fail and some they work. Try to drill down the problem and it the ehCache. It is being shut-down.

Can any body please explain me why this exception occur in Junt testing and that to not all the time. 
Please Note we have test cases for "Action" classes as well(Which deal with Servlet Context)
But interesting point all action test classes are getting passed.

Error Message is :
   java.lang.IllegalStateException: The CacheManager has been shut down. It can no longer be used.
    at net.sf.ehcache.CacheManager.checkStatus(CacheManager.java:1504)
    at net.sf.ehcache.CacheManager.getCacheNames(CacheManager.java:1491)
    at net.sf.ehcache.CacheManager.clearAll(CacheManager.java:1526)
Was it helpful?

Solution 2

I figured out what went wrong. One of the Junit is taking time to complete and it is a DAO. That method is taking around 40 to 50 Minutes to complete AND and session timed out for Cache Manager happens and when other Junit try to access I am getting that error. I fixed the Junit means basically the Query of the DAO to run quicker and all works good.

OTHER TIPS

Some part of your code is shutting down the cache manager (probably in the tear down of the unit test) and then trying to clear the cache. You can see this in the stack trace:

at net.sf.ehcache.CacheManager.clearAll(CacheManager.java:1526)

But once the manager is shut-down you cannot invoke operations on it. Without seeing the code of one of the unit tests, its hard to be more specific.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top