Class Loading error

Posted on

I am using the Jedis implementation of Redis cache. I am able to get/put key-value in the cache by just creating an object of the cachingservice client and calling the get or put methods. This serializes the object into byte array during PUT operation & deserializes to java.lang.Object during GET operation.
The cachingservice has been packed as a JAR in the services using caching.

There is an EJB interceptor in cachingservice which calls get/put method of the cachingservice itself. This interceptor annotation is used in other services over methods which use the cache.

Now, I am able to put the value in the cache using the interceptor annotation but getting the value from the cache using the interceptor is throwing ClassNotFoundException, as it is trying to convert java.lang.Object (which it got from the cache) to the return type of the method calling the cache. This return type is an XMLBean class.

To sum up, if I create & use cachingservice object in the consumer service, instead of interceptor for get & put, I do not get ClassNotFoundException & everything works fine. But upon using interceptor it throws ClassNotFoundException as it is trying to convert java.lang.Object (which it got from the cache) to the return type of the method calling the cache.

How do I solve this class loading issue?

Responses