JBoss Community

Re: ClassCastException with Infinispan using multiple applications

created by Dmitry Chuiko in JBoss AS 7 Development - View the full discussion

We encountered the similar issue trying to share some objects of the same class between several applications (several ears deployed on one jboss 7 instance) using replicated cache. It is worth noting there is no such problem then applications are deployed on different jboss instances. In this case marshalling works correctly after specifying a specific classloader using:  getAdvancedCache().with(<class_name>.class.getClassLoader()); But when all ears deployed in the same jboss instance the following scenario doesn't work:

1) first app put Foo object into cache

2) second app trying to get Foo object using the same key

2.1) cached object found successfully

2.2) ClassCastException occurs trying to cast the found object to class Foo because its class was loaded using classloader from the first app!

In this case cache marshalling doesn't try to determine the correct class and simply returns the existing Foo object.

 

Is there any opportunity to get replicated cache working in local mode? We are using 7.1.1 Final. Thanks in advance!

Reply to this message by going to Community

Start a new discussion in JBoss AS 7 Development at Community