[wildfly-dev] ClassCastException when get Object from Replicated Cache after redeploy

Domenico Briganti dometec at gmail.com
Mon Nov 11 12:32:43 EST 2013


Hi Paul.
 The code:

@Resource(lookup = "java:jboss/infinispan/container/reservation")
private CacheContainer container;

public Cache<K, V> getCache() {
  if (cache == null)
    cache = container.getCache(cachename);
  return cache;
}

Domenico

Il giorno lun, 11/11/2013 alle 09.52 -0500, Paul Ferraro ha scritto:
> How did you obtain your cache instance?
> 
> On Sun, 2013-11-10 at 11:32 +0100, Domenico Briganti wrote:
> > Hi all, 
> > I'm using an Infinispan Replicated cache with WildFly Beta 1. It
> > happen that when I get a value from cache after a redeploy a get a
> > ClassCastException:
> > a.b.C cannot be cast to a.b.C.
> > 
> > Certainly this is for modular class loader of WildFly.
> > 
> > Now I resolved the issue cloning the object on ClassCastException:
> > 
> > try {
> > AuthUserEntry authUserEntry = getCache().get(key);
> > return authUserEntry;
> > } catch (ClassCastException e) {
> > return DeepCopy.copy(getCache().get(key));
> > }
> > 
> > Not so elegant, but it works.
> > There is a better solution?
> > 
> > Thank you,
> > Domenico 
> > 
> > _______________________________________________
> > wildfly-dev mailing list
> > wildfly-dev at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/wildfly-dev
> 
> 





More information about the wildfly-dev mailing list