Hazelcast Spring Boot java.lang.ClassNotFoundException

I am starting hazelcast instance in my spring boot application.

Hazelcast configuration

@Configuration

@EnableCaching

public class HazelcastConfig {

@Bean

public Config hazelCastConfig() {

final Config config = new Config();

config.setClassLoader(getClass().getClassLoader());

config.setInstanceName("cache");

return config;

}

@Bean

public HazelcastInstance hazelcastInstance() {

return Hazelcast.newHazelcastInstance(hazelCastConfig());

}

}

And it fails time to time with class not found exception when I call my HTTP endpoint that queries data from hazelcast Map.

java.lang.ClassNotFoundException: com.someOrg.SomeClass

at org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoader.loadClass(TomcatEmbeddedWebappClassLoader.java:70) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]

at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1137) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]

at com.hazelcast.nio.ClassLoaderUtil.tryLoadClass(ClassLoaderUtil.java:173) ~[hazelcast-3.9.4.jar!/:3.9.4]

at com.hazelcast.nio.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:147) ~[hazelcast-3.9.4.jar!/:3.9.4]

at com.hazelcast.nio.IOUtil$ClassLoaderAwareObjectInputStream.resolveClass(IOUtil.java:593) ~[hazelcast-3.9.4.jar!/:3.9.4]

at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1826) ~[na:1.8.0_131]

at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1713) ~[na:1.8.0_131]

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2000) ~[na:1.8.0_131]

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1535) ~[na:1.8.0_131]

at java.io.ObjectInputStream.readObject(ObjectInputStream.java:422) ~[na:1.8.0_131]

at com.hazelcast.internal.serialization.impl.JavaDefaultSerializers$JavaSerializer.read(JavaDefaultSerializers.java:79) ~[hazelcast-3.9.4.jar!/:3.9.4]

at com.hazelcast.internal.serialization.impl.JavaDefaultSerializers$JavaSerializer.read(JavaDefaultSerializers.java:72) ~[hazelcast-3.9.4.jar!/:3.9.4]

at com.hazelcast.internal.serialization.impl.StreamSerializerAdapter.read(StreamSerializerAdapter.java:48) ~[hazelcast-3.9.4.jar!/:3.9.4]

at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toObject(AbstractSerializationService.java:191) ~[hazelcast-3.9.4.jar!/:3.9.4]

at com.hazelcast.query.impl.CachedQueryEntry.getValue(CachedQueryEntry.java:75) ~[hazelcast-3.9.4.jar!/:3.9.4]

at com.hazelcast.query.impl.CachedQueryEntry.getTargetObject(CachedQueryEntry.java:108) ~[hazelcast-3.9.4.jar!/:3.9.4]

at com.hazelcast.query.impl.QueryableEntry.extractAttributeValue(QueryableEntry.java:81) ~[hazelcast-3.9.4.jar!/:3.9.4]

at com.hazelcast.query.impl.QueryableEntry.getAttributeValue(QueryableEntry.java:48) ~[hazelcast-3.9.4.jar!/:3.9.4]

at com.hazelcast.query.impl.predicates.AbstractPredicate.readAttributeValue(AbstractPredicate.java:132) ~[hazelcast-3.9.4.jar!/:3.9.4]

at com.hazelcast.query.impl.predicates.AbstractPredicate.apply(AbstractPredicate.java:57) ~[hazelcast-3.9.4.jar!/:3.9.4]

at...

Read More »

By: StackOverFlow - 5 days ago

Related Posts