mercredi 27 mai 2015

ClassCastException while reading from Infinispan Cache after redeployment on Wildfly 8.2

I have a simple Infinispan local-cache (also tried distributed cache) on Wildfly 8.2. Everything is working fine until I do redeployment of my .WAR. After redeployment of my .WAR I get the following error:

Caused by: java.lang.ClassCastException: my.package.MyClass cannot be cast to my.package.MyClass

I lookup the Cache in a CDI Bean like this:

@Resource(lookup = CacheConstants.JNDI_CACHE_CONTAINER)
private CacheContainer container;

private Cache<String, MyClass> myCache;

.....

@PostConstruct
public void start() {
    myCache = container.getCache(CacheConstants.MyCacheName);
}

I know that the error occured because off different class loaders. Infinispan tries to cast the entity stored with the previous classloader which cannot work. But how to avoid this?

Aucun commentaire:

Enregistrer un commentaire