hi,
I put a cache entry into Infinispan server via hotrod,the value of the cache entry is a custom POJO class.when I try to get the value of the entry in CacheEntryModifiedEvent listener,I got the ClassCastException as below,I know this exception caused by load same class by different classloader,Does anyone can help me how to resolve this problem,thanks a million!
my code in event listener as below,pls FYI.
@CacheEntryModified | ||||
public void getValue(CacheEntryModifiedEvent event) { | ||||
if(!event.isPre()) | ||||
{ | ||||
try { | ||||
Object value = event.getValue(); | ||||
CacheValue value1 = (CacheValue)value; | ||||
User userValue = (User)marshaller.objectFromByteBuffer(value1.data()); | ||||
System.out.println(userValue.getUserName()); | ||||
} catch (IOException e) { | ||||
// TODO Auto-generated catch block | ||||
e.printStackTrace(); | ||||
} catch (ClassNotFoundException e) { | ||||
// TODO Auto-generated catch block | ||||
e.printStackTrace(); | ||||
} | ||||
} |
the exception log:
Caused by: java.lang.ClassCastException: com.redhat.datagrid.test.User cannot be cast to com.redhat.datagrid.test.User
at com.szse.sample.PrintWhenAdded.getValue(PrintWhenAdded.java:64)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_37]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_37]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_37]
at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_37]
at org.infinispan.notifications.AbstractListenerImpl$ListenerInvocation$1.run(AbstractListenerImpl.java:200) [infinispan-core-5.1.7.Final-redhat-1.jar:5.1.7.Final-redhat-1]
... 52 more