Originally, we had EhCache 2.5.1 libs deployed to Tomcat/lib and our app deployed to Tomcat/webapps/ROOT.
We made a change as I described in that post to switch some Sets/Maps stored in our cache values to ConcurrentHashMaps and ConcurrentHashMap-backed Sets.
After that change, we started seeing the following error on startup:
Code:
ay 09, 2014 4:56:35 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet action threw exception
java.lang.ClassNotFoundException: javax.transaction.TransactionManager
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2397)
at java.lang.Class.getDeclaredFields(Class.java:1806)
at net.sf.ehcache.pool.sizeof.ObjectGraphWalker.getAllFields(ObjectGraphWalker.java:266)
at net.sf.ehcache.pool.sizeof.ObjectGraphWalker.getFilteredFields(ObjectGraphWalker.java:229)
at net.sf.ehcache.pool.sizeof.ObjectGraphWalker.walk(ObjectGraphWalker.java:160)
at net.sf.ehcache.pool.sizeof.SizeOf.deepSizeOf(SizeOf.java:73)
at net.sf.ehcache.pool.impl.DefaultSizeOfEngine.sizeOf(DefaultSizeOfEngine.java:173)
at net.sf.ehcache.pool.impl.AbstractPoolAccessor.add(AbstractPoolAccessor.java:63)
at net.sf.ehcache.store.MemoryStore.put(MemoryStore.java:258)
at net.sf.ehcache.store.MemoryStore.fill(MemoryStore.java:237)
at net.sf.ehcache.store.FrontEndCacheTier.put(FrontEndCacheTier.java:259)
at net.sf.ehcache.Cache.putInternal(Cache.java:1489)
at net.sf.ehcache.Cache.put(Cache.java:1417)
at net.sf.ehcache.Cache.put(Cache.java:1382)
at com.hannonhill.cascade.cache.DefaultEhcacheIndexBlockRenderCache.store(DefaultEhcacheIndexBlockRenderCache.java:695)
It would happen on the first request and would go away after that. This was odd because:
Our app supplies jta.jar containing javax.transaction.TransactionManager in our app's WEB-INF/lib directory. Plus, the error seems to go away on the next request indicating some kind of weird classloading race condition or something
None of our cache data structures seem to be referencing the TransactionManager. We do make cache calls from within a Spring-annotated tx though but I'm not sure why EhCache would suddenly need to access the TransactionManager when computing the size of our cache entries
Then, we moved EhCache into our app's libs instead of having it in Tomcat/lib and this error mysteriously went away.
We're fine with this change, but:
Why couldn't EhCache find the TransactionManager before?
Is there any problem with deploying EhCache to our webapp's WEB-INF/lib? This article seems to recommend deploying it to Tomcat/common/lib but I was wondering if that was kind of a legacy recommendation since Tomcat/common doesn't even exist in T6+
Thanks!