java.lang.IllegalArgumentException: can't serialize class java.time.LocalDateTime

Spring JIRA | Bjorn Harvold | 11 months ago
  1. 0

    Morphia can't insert class into DB

    Stack Overflow | 2 years ago | nazar_art
    java.lang.IllegalArgumentException: can't serialize class com.aerlingus.ta.models.b2b.faresearch.AirSearchPrefsType$CabinPref
  2. Speed up your debug routine!

    Automated exception search integrated into your IDE

  3. 0

    Inserting Java Object to MongoDB Collection Using Java

    wenda.io | 1 year ago
    java.lang.IllegalArgumentException: can't serialize class net.sf.json.JSONNull
  4. 0

    I get an "IllegalArgumentException: can't serialize class" every time I use an {{enum}} or {{LocalDateTime}} (and problably other java.time classes) in a {{Criteria}} that is then handed to a distinct query. Since the same is working with simple find queries I guess it's a bug around using {{Criteria}} with distinct. Here is a sample code: {code:java} public List<BasicDBObject> retrieveDistinctDocuments(LocalDateTime from, LocalDateTime to) { Query query = new Query(Criteria.where(FIELD_TIME).gte(from).lte(to)); return mongoTemplate.getCollection(COLLECTION_NAME).distinct(FIELD_NAME, query.getQueryObject()); } {code} See stacktrace: {noformat} java.lang.IllegalArgumentException: can't serialize class java.time.LocalDateTime at org.bson.BasicBSONEncoder._putObjectField(BasicBSONEncoder.java:299) at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:194) at org.bson.BasicBSONEncoder._putObjectField(BasicBSONEncoder.java:255) at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:194) at org.bson.BasicBSONEncoder._putObjectField(BasicBSONEncoder.java:255) at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:194) at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:136) at com.mongodb.DefaultDBEncoder.writeObject(DefaultDBEncoder.java:36) at com.mongodb.OutMessage.putObject(OutMessage.java:289) at com.mongodb.OutMessage.writeQuery(OutMessage.java:211) at com.mongodb.OutMessage.query(OutMessage.java:86) at com.mongodb.DBCollectionImpl.find(DBCollectionImpl.java:81) at com.mongodb.DB.command(DB.java:320) at com.mongodb.DB.command(DB.java:299) at com.mongodb.DBCollection.distinct(DBCollection.java:1475) at com.mongodb.DBCollection.distinct(DBCollection.java:1455) {noformat}

    Spring JIRA | 8 months ago | Balazs Peterfi
    java.lang.IllegalArgumentException: can't serialize class java.time.LocalDateTime

    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 java.time.LocalDateTime

      at org.bson.BasicBSONEncoder._putObjectField()
    2. MongoDB Java Driver
      BasicBSONEncoder._putObjectField
      1. org.bson.BasicBSONEncoder._putObjectField(BasicBSONEncoder.java:299)
      1 frame