aspose file tools*
The moose likes EhCache and the fly likes classloader conflict using mybatis/ehcache/terracotta within a custom container Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Caching » EhCache
Bookmark "classloader conflict using mybatis/ehcache/terracotta within a custom container" Watch "classloader conflict using mybatis/ehcache/terracotta within a custom container" New topic
Author

classloader conflict using mybatis/ehcache/terracotta within a custom container

kato Kwong
Greenhorn

Joined: Sep 23, 2011
Posts: 27
Hello.

I am using MyBatis 3.1.1, mybatis-ehcache 1.0.0, mybatis-spring 1.1.0 with Spring 3.0.6 and Ehcache 2.0 for caching. I would also like to use Terracotta for a distributed cache at some future date.

I am forced to deploy my application in a container that is itself an application. Unfortunately, it uses Ehcache itself. This would not be a problem except the classloader of this container application is used by my application to find . And of course it does not find my version but the container version which then cannot find my application ehcache.xml.

I have tried moving my config file to the container classpath and that seems to work. I have also tried to remove the container Ehcache JAR, which also works. Unfortunately, neither is an option moving forward.

So I am wondering what I can do. Is there a way to configure MyBatis to use a specific version of Ehcache? Alternatively, I could configure my ehcaches through MyBatis, but I am worried I won't have access to the full range of Ehcache properties, especially the terracotta element. Here is my ehcache.xml



Could I write my own class that wraps org.mybatis.caches.ehcache.EhcacheCache and somehow loads the correct Ehcache library or at least config file?

Or should I cut my losses and try to use a different caching solution?

Any ideas appreciated.

Cheers
Kato
 
jQuery in Action, 2nd edition
 
subject: classloader conflict using mybatis/ehcache/terracotta within a custom container