java.lang.IllegalArgumentException: can't serialize class Type

JIRA | Robert Stiller | 6 years ago
  1. 0

    Enums cannot be serialized without transforming them. I propose, that all java enums are serialized (and deserialized) using the name() method (or valueOf() method). Example (using QueryDSL): @Entity public enum Type { TYPE1, TYPE2 } public class MyObject { protected Type type; public Type getType() { } public void setType(Type type) { this.type = type; } } Usage: QMyObject.myObject.type.eq(Type.TYPE1); // ends in: java.lang.IllegalArgumentException: can't serialize class Type at org.bson.BSONEncoder._putObjectField(BSONEncoder.java:213) at org.bson.BSONEncoder.putObject(BSONEncoder.java:123) at org.bson.BSONEncoder._putObjectField(BSONEncoder.java:173) at org.bson.BSONEncoder.putObject(BSONEncoder.java:123) at org.bson.BSONEncoder.putObject(BSONEncoder.java:69) at com.mongodb.OutMessage.putObject(OutMessage.java:189) at com.mongodb.OutMessage._appendQuery(OutMessage.java:62) at com.mongodb.OutMessage.query(OutMessage.java:39) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:293) at com.mongodb.DB.command(DB.java:152) at com.mongodb.DBCollection.getCount(DBCollection.java:760) at com.mongodb.DBCollection.getCount(DBCollection.java:731) at com.mongodb.DBCollection.count(DBCollection.java:697) at com.mysema.query.mongodb.MongodbQuery.count(MongodbQuery.java:184) at org.springframework.data.document.mongodb.repository.QueryDslMongoRepository.count(QueryDslMongoRepository.java:151) at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at org.springframework.data.repository.support.RepositoryFactorySupport$QueryExecuterMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:356) at org.springframework.data.repository.support.RepositoryFactorySupport$QueryExecuterMethodInterceptor.invoke(RepositoryFactorySupport.java:337) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at $Proxy18.count(Unknown Source)

    JIRA | 6 years ago | Robert Stiller
    java.lang.IllegalArgumentException: can't serialize class Type
  2. 0

    Akka configured seed nodes are leaving cluster and unreachable/reachable warning message is getting logged.

    Google Groups | 3 months ago | vipin mandloi
    java.lang.IllegalArgumentException: Can't serialize object of type class org.springframework.context.support.ClassPathXmlApplicationContext*
  3. 0

    GPMONGODB-45: java.lang.IllegalArgumentException: can't serialize class java.math.BigDecimal

    GitHub | 6 years ago | graemerocher
    java.lang.IllegalArgumentException: can't serialize class java.math.BigDecimal
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    GPMONGODB-137: CLONE - java.lang.IllegalArgumentException: can't serialize class java.math.BigDecimal

    GitHub | 5 years ago | graemerocher
    java.lang.IllegalArgumentException: can't serialize class java.math.BigDecimal
  6. 0

    spring-data-mongodb - 1.3.3.RELEASE mongo-java-driver - 2.11.3 Unable to execute query using void org.springframework.data.mongodb.core.MongoTemplate.executeQuery(Query query, String collectionName, DocumentCallbackHandler dch) with queries which contain Criteries with Enums. {code:title=Stack trace}: java.lang.IllegalArgumentException: can't serialize class Day at org.bson.BasicBSONEncoder._putObjectField(BasicBSONEncoder.java:273) at org.bson.BasicBSONEncoder.putIterable(BasicBSONEncoder.java:298) at org.bson.BasicBSONEncoder._putObjectField(BasicBSONEncoder.java:237) at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:174) at org.bson.BasicBSONEncoder._putObjectField(BasicBSONEncoder.java:229) at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:174) at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:120) at com.mongodb.DefaultDBEncoder.writeObject(DefaultDBEncoder.java:27) at com.mongodb.OutMessage.putObject(OutMessage.java:289) at com.mongodb.OutMessage.writeQuery(OutMessage.java:211) at com.mongodb.OutMessage.query(OutMessage.java:84) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:285) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:273) at com.mongodb.DBCursor._check(DBCursor.java:368) at com.mongodb.DBCursor._hasNext(DBCursor.java:459) at com.mongodb.DBCursor.hasNext(DBCursor.java:484) at org.springframework.data.mongodb.core.MongoTemplate.executeQueryInternal(MongoTemplate.java:1701) at org.springframework.data.mongodb.core.MongoTemplate.executeQuery(MongoTemplate.java:377) at org.springframework.data.mongodb.core.MongoTemplate.executeQuery(MongoTemplate.java:350) {code} Please find little unit test in attachment

    Spring JIRA | 3 years ago | Alex_M
    java.lang.IllegalArgumentException: can't serialize class Day

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalArgumentException

      can't serialize class Type

      at org.bson.BSONEncoder._putObjectField()
    2. MongoDB Java Driver
      DBCollection.count
      1. org.bson.BSONEncoder._putObjectField(BSONEncoder.java:213)
      2. org.bson.BSONEncoder.putObject(BSONEncoder.java:123)
      3. org.bson.BSONEncoder._putObjectField(BSONEncoder.java:173)
      4. org.bson.BSONEncoder.putObject(BSONEncoder.java:123)
      5. org.bson.BSONEncoder.putObject(BSONEncoder.java:69)
      6. com.mongodb.OutMessage.putObject(OutMessage.java:189)
      7. com.mongodb.OutMessage._appendQuery(OutMessage.java:62)
      8. com.mongodb.OutMessage.query(OutMessage.java:39)
      9. com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:293)
      10. com.mongodb.DB.command(DB.java:152)
      11. com.mongodb.DBCollection.getCount(DBCollection.java:760)
      12. com.mongodb.DBCollection.getCount(DBCollection.java:731)
      13. com.mongodb.DBCollection.count(DBCollection.java:697)
      13 frames
    3. Querydsl - Mongodb support
      MongodbQuery.count
      1. com.mysema.query.mongodb.MongodbQuery.count(MongodbQuery.java:184)
      1 frame
    4. org.springframework.data
      QueryDslMongoRepository.count
      1. org.springframework.data.document.mongodb.repository.QueryDslMongoRepository.count(QueryDslMongoRepository.java:151)
      1 frame
    5. Java RT
      Method.invoke
      1. sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
      2. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      3. java.lang.reflect.Method.invoke(Method.java:616)
      3 frames
    6. Spring Data Core
      RepositoryFactorySupport$QueryExecuterMethodInterceptor.invoke
      1. org.springframework.data.repository.support.RepositoryFactorySupport$QueryExecuterMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:356)
      2. org.springframework.data.repository.support.RepositoryFactorySupport$QueryExecuterMethodInterceptor.invoke(RepositoryFactorySupport.java:337)
      2 frames
    7. Spring AOP
      JdkDynamicAopProxy.invoke
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      2. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      2 frames
    8. Unknown
      $Proxy18.count
      1. $Proxy18.count(Unknown Source)
      1 frame