0

I have a hazelcast Member that uses Jcache. I am using CacheLoader and CacheWriter for Jcache.

On another member that is clustering, I am getting an exception that one of the Jcache CacheLoader classes can't be loaded. The cacheloader is defined as an internal private static class.

Below is what my usercode deployment config looks like on both members.

<user-code-deployment enabled="true">
    <class-cache-mode>ETERNAL</class-cache-mode>
    <provider-mode>LOCAL_CLASSES_ONLY</provider-mode>
</user-code-deployment>

The exception I get is:

com.hazelcast.nio.serialization.HazelcastSerializationException: java.lang.ClassNotFoundException: Failed to load class app.cache.HzAuthCacheManagerImpl$DefaultCacheLoader from other members.
    at com.hazelcast.internal.serialization.impl.JavaDefaultSerializers$JavaSerializer.read(JavaDefaultSerializers.java:83)
    at com.hazelcast.internal.serialization.impl.JavaDefaultSerializers$JavaSerializer.read(JavaDefaultSerializers.java:72)

Caused by: java.lang.ClassNotFoundException: Failed to load class app.cache.HzAuthCacheManagerImpl$DefaultCacheLoader from other members.
    at com.hazelcast.internal.usercodedeployment.impl.ClassLocator.tryToGetClassFromRemote(ClassLocator.java:157)
    at com.hazelcast.internal.usercodedeployment.impl.ClassLocator.handleClassNotFoundException(ClassLocator.java:95)
    at com.hazelcast.internal.usercodedeployment.UserCodeDeploymentService.handleClassNotFoundException(UserCodeDeploymentService.java:89)

I don't get any exception on the member that has HzAuthCacheManagerImpl defined.

Is there anything wrong in my configuration or something else is needed to get usercode deployment working with JCache?

Manish
  • 909
  • 1
  • 11
  • 23
  • Can you also post some additional info: cache configuration, how do you configure and obtain the cache on each member (programmatically, declaratively or dynamically via `CacheManager.createCache`)? – Vassilis Bekiaris Jul 26 '18 at 10:02
  • I am doing it programmatically. cachingProvider = HazelcastServerCachingProvider.createCachingProvider(hazelcastInstance); cacheManager = cachingProvider.getCacheManager(); tokenPolicyBeanCache = getReadThroughCache("tokenPolicyCache", String.class,AuthTokenPolicyBean.class); userCache = getReadThroughCache("userCache",String.class,UserBean.class, new UserCacheLoader()); – Manish Jul 30 '18 at 05:17
  • Can you post the actual `Cache` configuration? This must be defined somewhere within your `getReadThroughCache` method. As a side note on a different topic, `HazelcastServerCachingProvider#createCachingProvider` is not public API (class is in `impl` package). See an example of obtaining a `CacheManager` backed by an existing `HazelcastInstance` here http://docs.hazelcast.org/docs/3.10.4/manual/html-single/index.html#reusing-existing-code-hazelcastinstance-code-with-the-default-code-cachemanager-code – Vassilis Bekiaris Jul 31 '18 at 06:12
  • I was doing it wrong on my side. I'll close the question. – Manish Aug 15 '18 at 01:10

0 Answers0