Serialization exception in HazelCast 3.5 with Scala - scala

I am using Hazelcast 3.5 with scala
i have a case class Abc i am trying to store object of my class in hazelcast from my client but it gives me some serialization exception
here is my class
#SerialVersionUID(1)
case class Abc( id : Int ,name : String , subjectCode : MutableList[Int]) extends Serialable
when i run the client code it gives me following exception
18:33:43.274 [hz._hzInstance_1_dev.partition-operation.thread-1] ERROR c.h.map.impl.operation.PutOperation - [192.168.15.20]:5701 [dev] [3.5] java.lang.ClassNotFoundException: scala.collection.mutable.MutableList
com.hazelcast.nio.serialization.HazelcastSerializationException: java.lang.ClassNotFoundException: scala.collection.mutable.MutableList
at com.hazelcast.nio.serialization.DefaultSerializers$ObjectSerializer.read(DefaultSerializers.java:201) ~[hazelcast-3.5.jar:3.5]
at com.hazelcast.nio.serialization.StreamSerializerAdapter.read(StreamSerializerAdapter.java:41) ~[hazelcast-3.5.jar:3.5]
at com.hazelcast.nio.serialization.SerializationServiceImpl.toObject(SerializationServiceImpl.java:276) ~[hazelcast-3.5.jar:3.5]
at com.hazelcast.map.impl.mapstore.AbstractMapDataStore.toObject(AbstractMapDataStore.java:78) ~[hazelcast-3.5.jar:3.5]

Your cluster must run with the same codebase (in this case the scala jar) as your clients.

Related

Spark Kryo Serialization issue

I have a Spark job that have been working well till a few days ago I needed to enable Kryo Serialization.
spark.kryo.registrationRequired true
spark.kryo.referenceTracking true
spark.kryo.registrator org.mycompany.serialization.MyKryoRegistrator
spark.serializer org.apache.spark.serializer.KryoSerializer
Now it started to complain it can not find registered classes. I registered like this
def registerByName(kryo: Kryo, name: String) = kryo.register(Class.forName(name))
registerByName(kryo, "org.apache.spark.util.collection.BitSet")
registerByName(kryo, "org.apache.spark.util.collection.OpenHashSet")
registerByName(kryo, "org.apache.spark.util.collection.OpenHashSet$Hasher")
registerByName(kryo, "org.apache.spark.util.collection.OpenHashMap")
registerByName(kryo, "org.apache.spark.util.collection.OpenHashMap$mcJ$sp")
After this it complains with
com.esotericsoftware.kryo.KryoException: java.lang.IllegalArgumentException: Class is not registered: org.apache.spark.util.collection.OpenHashMap$mcJ$sp$$Lambda$1429/0x0000000800cd3840
Note: To register this class use: kryo.register(org.apache.spark.util.collection.OpenHashMap$mcJ$sp$$Lambda$1429/0x0000000800cd3840.class
But if I try register
registerByName(kryo, "org.apache.spark.util.collection.OpenHashMap$mcJ$sp$$Lambda$1429/0x0000000800cd3840")
it throws java.lang.ClassNotFoundException
The class OpenHashMap is private for [spark] package scala generic that is used somewhere in deeps of Spark and seems like once Kryo is enabled, Spark offloads all serialization things related to its internals to Kryo. If it was my class I would write custom serializer but I have no Idea what can I do in my situation.
The problematic class definition https://github.com/apache/spark/blob/master/core/src/main/scala/org/apache/spark/util/collection/OpenHashMap.scala

spring cloud stream binder kafka doesn't work

Now I'm trying to create Message Service function with kafka to use spring-cloud-stream-bind-kafka, but didn't work so well.
Configuration:
spring boot 1.4.2
build.gradle:
compile "org.springframework.cloud:spring-cloud-stream:2.0.1.RELEASE"
compile "org.springframework.cloud:spring-cloud-stream-binder-kafka:2.0.1.RELEASE"
code:
#EnableBindings(MessagePublish.class)
class MessageConfiguration {
}
interface MessagePublish {
#Output("test")
MessageChannel publish();
}
class TestService {
#Autowired
MessagePublish messagePublish;
public void doSomething() {
// do something
messagePublish.publish().send(MessageBuilder.withPayload("test").build());
}
}
It failed when I start the project with this error log
Caused by: org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanTypeDeductionException: Failed to deduce bean type for org.springframework.cloud.stream.config.BindingServiceConfiguration.bindingService
....
Caused by: java.lang.ClassNotFoundException: org.springframework.integration.support.converter.ConfigurableCompositeMessageConverter
I'm suspecting my spring boot version. It's so low version.
I think spring-cloud-stream-binder-kafka can't be used under spring boot 2.0 version or other reasons.
I don't know how can I do and how can I explore this situation...
If you give me a little advice, I really appreciate you.
If you are using Spring Boot 1.4.x version then you should use the Spring Cloud Camden release train.
https://github.com/spring-projects/spring-cloud/wiki/Spring-Cloud-Camden-Release-Notes
In particular, you should use the following versions:
compile "org.springframework.cloud:spring-cloud-stream:1.1.2.RELEASE"
compile "org.springframework.cloud:spring-cloud-stream-binder-kafka:1.1.2.RELEASE"

Cglib proxy errors using and Spring Data when moving from Spring XD M5 to Release 1.0.0

We're moving a number of batch jobs from Spring XD M5 to the 1.0.0 release.
When creating and deploying the jobs, we are hitting an issue with cglib proxy functionality when autowiring Spring Data repositories (for Neo4J in this case).
The tail end of the stack trace:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'datasetRepository': Post-processing of FactoryBean's singleton object failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class
com.sun.proxy.$Proxy112]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Cannot subclass final class class com.sun.proxy.$Proxy112
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:116)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1512)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:313)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1017)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:960)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:858)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)
... 54 more
Caused by: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class com.sun.proxy.$Proxy112]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Cannot subclass final
class class com.sun.proxy.$Proxy112
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:212)
at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:109)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:494)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:379)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:339)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:421)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.postProcessObjectFromFactoryBean(AbstractAutowireCapableBeanFactory.java:1698)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:113)
... 61 more
Caused by: java.lang.IllegalArgumentException: Cannot subclass final class class com.sun.proxy.$Proxy112
at org.springframework.cglib.proxy.Enhancer.generateClass(Enhancer.java:446)
at org.springframework.cglib.transform.TransformingClassGenerator.generateClass(TransformingClassGenerator.java:33)
at org.springframework.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:317)
at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:57)
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:202)
... 68 more
The Spring Data repository interface is annotated with #Repository as follows:
#Repository
public interface DatasetRepository extends GraphRepository<Dataset>
{
public Dataset findOneById(String id);
public Dataset findOneByName(String name);
}
And the corresponding autowired attribute in our bean class which triggers the exception:
#Autowired
private DatasetRepository datasetRepo;
The bean itself is defined in our XD job XML as follows:
<bean id="myBean" class="com.mycompany.MyBean"/>
And the configuration bean (component scanned in the job cfg XML):
#Configuration
#EnableNeo4jRepositories({ "com.mycompany.repositories" })
public class CustomNeo4jConfiguration implements InitializingBean
The versions of Spring Data Neo4J which we deploy into the XD lib folder are as follows:
spring-data-neo4j : 3.2.0.RELEASE
spring-data-neo4j-rest : 3.2.0.RELEASE
The setup is all on a dev PC (for now) with XD running in distributed mode:
redis server
Zookeeper server (1x)
Oracle job repository (local XE instance for now)
1x admin and 1x container
Any help around configuration of the job, Spring Data repository or XD container would be much appreciated.
Thanks
Remove the #Repository annotation on your GraphRepository and you should be fine. Don't forget to enable component scanning.

spring data redis Failed to deserialize object type; nested exception is java.lang.ClassNotFoundException

I am using spring-data-redis 1.1.0 and jedis 2.1.0.
When i deploy my code to Karaf, i'am getting the below exception:
Is the byte array a result of corresponding serialization for DefaultDeserializer?;
nested exception is org.springframework.core.NestedIOException: Failed to deserialize object type;
nested exception is java.lang.ClassNotFoundException
It is working when my i am running JUnit.
Below is my redisTemplate.
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">

DuplicateMemberException play framework mongodb module

I get this error on starting play application. Im using Play 1.2.4 and Mongo 1.3 module.
`Oops: DuplicateMemberException
An unexpected error occured caused by exception DuplicateMemberException: duplicate method: getCollectionName in models.MongoShapes
play.exceptions.UnexpectedException: While applying play.modules.mongo.MongoPlugin#2d7cec96 on models.MongoShapes
at play.plugins.PluginCollection.enhance(PluginCollection.java:511)
at play.classloading.ApplicationClasses$ApplicationClass.enhance(ApplicationClasses.java:235)
at play.classloading.ApplicationClassloader.loadApplicationClass(ApplicationClassloader.java:165)
at play.classloading.ApplicationClassloader.getAllClasses(ApplicationClassloader.java:429)
at play.Play.start(Play.java:505)
at play.Play.detectChanges(Play.java:618)
at play.Invoker$Invocation.init(Invoker.java:198)
at Invocation.HTTP Request(Play!)
Caused by: javassist.bytecode.DuplicateMemberException: duplicate method: getCollectionName in models.MongoShapes
at javassist.bytecode.ClassFile.testExistingMethod(ClassFile.java:593)
at javassist.bytecode.ClassFile.addMethod(ClassFile.java:577)
at javassist.CtClassType.addMethod(CtClassType.java:1235)
at play.modules.mongo.MongoEnhancer.enhanceMongoEntity(MongoEnhancer.java:69)
at play.modules.mongo.MongoEnhancer.enhanceThisClass(MongoEnhancer.java:35)
at play.modules.mongo.MongoPlugin.enhance(MongoPlugin.java:17)
at play.plugins.PluginCollection.enhance(PluginCollection.java:506)
... 7 more
My class looks like
#MongoEntity
public class MongoShapes extends MongoModel{
String someComment;
}
Looks like your project include mongo module more than once. How did you declare mongo module? don't declare it in both applicaiton.conf and dependencies.yml.