[JAVA-1585] ClassMapBasedObjectserialzer fails occasionally with "json can't serialize type" message Created: 04/Dec/14  Updated: 23/Jun/15  Resolved: 23/Jun/15

Status: Closed
Project: Java Driver
Component/s: Write Operations
Affects Version/s: 2.12.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Manoj Kurup Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux ip-172-31-7-155 3.13.0-29-generic #53-Ubuntu SMP
MongoDB shell version: 2.6.3



 Description   

java.lang.RuntimeException: json can't serialize type : class com.viditure.entities.DocRecipient
	at com.mongodb.util.ClassMapBasedObjectSerializer.serialize(ClassMapBasedObjectSerializer.java:77) ~[mongo-java-driver-2.12.1.jar:na]
	at com.mongodb.util.JSONSerializers$MapSerializer.serialize(JSONSerializers.java:317) ~[mongo-java-driver-2.12.1.jar:na]
	at com.mongodb.util.ClassMapBasedObjectSerializer.serialize(ClassMapBasedObjectSerializer.java:79) ~[mongo-java-driver-2.12.1.jar:na]
	at com.mongodb.util.JSONSerializers$MapSerializer.serialize(JSONSerializers.java:317) ~[mongo-java-driver-2.12.1.jar:na]
	at com.mongodb.util.ClassMapBasedObjectSerializer.serialize(ClassMapBasedObjectSerializer.java:79) ~[mongo-java-driver-2.12.1.jar:na]
	at com.mongodb.util.JSON.serialize(JSON.java:55) ~[mongo-java-driver-2.12.1.jar:na]
	at com.mongodb.util.JSON.serialize(JSON.java:40) ~[mongo-java-driver-2.12.1.jar:na]
	at com.mongodb.BasicDBObject.toString(BasicDBObject.java:83) ~[mongo-java-driver-2.12.1.jar:na]
	at org.springframework.data.mongodb.core.query.Update.toString(Update.java:375) ~[spring-data-mongodb-1.5.1.RELEASE.jar:na]
	at java.util.Formatter$FormatSpecifier.printString(Formatter.java:2838) ~[na:1.7.0_55]
	at java.util.Formatter$FormatSpecifier.print(Formatter.java:2718) ~[na:1.7.0_55]
	at java.util.Formatter.format(Formatter.java:2488) ~[na:1.7.0_55]
	at java.util.Formatter.format(Formatter.java:2423) ~[na:1.7.0_55]
	at java.lang.String.format(String.java:2797) ~[na:1.7.0_55]

In the operation we are trying to perform 'DocRecipient' , a POJO, is being updated in the main document through a findAndModify call.
Initial creation of the document had no issues and many documents with other DocRecipients are successfully created and updated - but on the cases where they fail they consistently with the stack trace above

JSON of the sample document which failed is shown below : it looks no different than the ones which pass. the JSON was printed in log using jackson

{
  "state" : "SEEN",
  "_id" : "547bd935e4b0ee388a96ad0d",
  "fullName" : "haksdfj",
  "email" : "xyz@gmail.com",
  "token" : "547bd935e4b0ee388a96ad0e",
  "signRequired" : false,
  "fieldInputs" : [ {
    "fieldPosition" : "0.0",
    "state" : "NOTFILLED"
  }, {
    "fieldPosition" : "0.1",
    "state" : "NOTFILLED"
  } ],
  "readOutMessage" : "I haksdfj agree to ....",
  "videoDuration" : 10,
  "timeAccessed" : 1417560518713
}



 Comments   
Comment by Jeffrey Yemin [ 06/Mar/15 ]

Hi there,

Sorry for losing track of this. Can you provide a small sample application that reproduces the problem? It's not clear why you would expect that a com.viditure.entities.DocRecipient embedded in a BasicDBObject could be serialized properly to JSON.

Thanks.

Generated at Thu Feb 08 08:54:59 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.