java.lang.IllegalArgumentException: Invalid BSON field name $uuid

JIRA | Sebastian Binder | 3 months ago
  1. 0

    Hello. I have a problem with Java UUID serialization. I'm having a UUID object and wanna serialize it: {code:title=Java|borderStyle=solid} JSON.serialize(myUuid) {code} Now when using this snipped in a more complex JSON as the following and parsing it with the code below the json, an error shows up. {code:title=json|borderStyle=solid} { "_id":"w1bEDr6", "server":"Lobby-01", "created":{ "$date":"2016-09-21T09:00:19.001Z" }, "messages":[ { "sender":{ "$uuid":"93ede72e-3ef0-42eb-a37b-62477df6497f" }, "message":"PLAYER_JOIN", "type":"EVENT", "timestamp":{ "$date":"2016-09-21T09:00:19.002Z" } }, { "sender":{ "$uuid":"93ede72e-3ef0-42eb-a37b-62477df6497f" }, "message":"/chatlog", "type":"COMMAND", "timestamp":{ "$date":"2016-09-21T09:00:23.821Z" } }, { "sender":{ "$uuid":"93ede72e-3ef0-42eb-a37b-62477df6497f" }, "message":"PLAYER_QUIT", "type":"EVENT", "timestamp":{ "$date":"2016-09-21T09:00:25.643Z" } } ] } {code} {code:title=Java|borderStyle=solid} Document.parse(json) {code} {code:title=Error|borderStyle=solid} java.lang.IllegalArgumentException: Invalid BSON field name $uuid at org.bson.AbstractBsonWriter.writeName(AbstractBsonWriter.java:494) at org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:188) at org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:172) at org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:189) at org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:172) at org.bson.codecs.DocumentCodec.writeIterable(DocumentCodec.java:197) at org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:170) at org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:189) at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:131) at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:45) at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63) at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29) at com.mongodb.connection.InsertCommandMessage.writeTheWrites(InsertCommandMessage.java:101) at com.mongodb.connection.InsertCommandMessage.writeTheWrites(InsertCommandMessage.java:43) at com.mongodb.connection.BaseWriteCommandMessage.encodeMessageBodyWithMetadata(BaseWriteCommandMessage.java:129) at com.mongodb.connection.RequestMessage.encodeWithMetadata(RequestMessage.java:160) at com.mongodb.connection.WriteCommandProtocol.sendMessage(WriteCommandProtocol.java:212) at com.mongodb.connection.WriteCommandProtocol.execute(WriteCommandProtocol.java:101) at com.mongodb.connection.InsertCommandProtocol.execute(InsertCommandProtocol.java:67) at com.mongodb.connection.InsertCommandProtocol.execute(InsertCommandProtocol.java:37) at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:159) at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:286) at com.mongodb.connection.DefaultServerConnection.insertCommand(DefaultServerConnection.java:115) at com.mongodb.operation.MixedBulkWriteOperation$Run$2.executeWriteCommandProtocol(MixedBulkWriteOperation.java:455) at com.mongodb.operation.MixedBulkWriteOperation$Run$RunExecutor.execute(MixedBulkWriteOperation.java:646) at com.mongodb.operation.MixedBulkWriteOperation$Run.execute(MixedBulkWriteOperation.java:401) at com.mongodb.operation.MixedBulkWriteOperation$1.call(MixedBulkWriteOperation.java:179) at com.mongodb.operation.MixedBulkWriteOperation$1.call(MixedBulkWriteOperation.java:168) at com.mongodb.operation.MixedBulkWriteOperation$1.call(MixedBulkWriteOperation.java:168) [14/9133] at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:230) at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:221) at com.mongodb.operation.MixedBulkWriteOperation.execute(MixedBulkWriteOperation.java:168) at com.mongodb.operation.MixedBulkWriteOperation.execute(MixedBulkWriteOperation.java:74) at com.mongodb.Mongo.execute(Mongo.java:781) at com.mongodb.Mongo$2.execute(Mongo.java:764) at com.mongodb.MongoCollectionImpl.executeSingleWriteRequest(MongoCollectionImpl.java:515) at com.mongodb.MongoCollectionImpl.insertOne(MongoCollectionImpl.java:306) at com.mongodb.MongoCollectionImpl.insertOne(MongoCollectionImpl.java:297) <rest of stacktrace removed> {code} Any idea what's going on here? Is this a bug or an error with my code?

    JIRA | 3 months ago | Sebastian Binder
    java.lang.IllegalArgumentException: Invalid BSON field name $uuid
  2. 0

    Cannot specify partialFilterExpression for a field in an array or subdocument

    GitHub | 1 month ago | paterczm
    java.lang.IllegalArgumentException: Invalid BSON field name authentications.providerName (...)
  3. 0

    Problem when inserting object with hashmap which keys contain a dot

    GitHub | 1 year ago | cteyton
    java.lang.IllegalArgumentException: Invalid BSON field name key.notOK
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Bulk upsert using MongoDb BulkWriteOperation throwing IllegalArgumentException

    Stack Overflow | 2 years ago
    java.lang.IllegalArgumentException: Invalid BSON field name code
  6. 0

    Exeption in MongoClient.update

    GitHub | 11 months ago | remi128
    java.lang.IllegalArgumentException: Invalid BSON field name intValue

    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

      Invalid BSON field name $uuid

      at org.bson.AbstractBsonWriter.writeName()
    2. MongoDB Java Driver
      MixedBulkWriteOperation$1.call
      1. org.bson.AbstractBsonWriter.writeName(AbstractBsonWriter.java:494)
      2. org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:188)
      3. org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:172)
      4. org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:189)
      5. org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:172)
      6. org.bson.codecs.DocumentCodec.writeIterable(DocumentCodec.java:197)
      7. org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:170)
      8. org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:189)
      9. org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:131)
      10. org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:45)
      11. org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63)
      12. org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29)
      13. com.mongodb.connection.InsertCommandMessage.writeTheWrites(InsertCommandMessage.java:101)
      14. com.mongodb.connection.InsertCommandMessage.writeTheWrites(InsertCommandMessage.java:43)
      15. com.mongodb.connection.BaseWriteCommandMessage.encodeMessageBodyWithMetadata(BaseWriteCommandMessage.java:129)
      16. com.mongodb.connection.RequestMessage.encodeWithMetadata(RequestMessage.java:160)
      17. com.mongodb.connection.WriteCommandProtocol.sendMessage(WriteCommandProtocol.java:212)
      18. com.mongodb.connection.WriteCommandProtocol.execute(WriteCommandProtocol.java:101)
      19. com.mongodb.connection.InsertCommandProtocol.execute(InsertCommandProtocol.java:67)
      20. com.mongodb.connection.InsertCommandProtocol.execute(InsertCommandProtocol.java:37)
      21. com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:159)
      22. com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:286)
      23. com.mongodb.connection.DefaultServerConnection.insertCommand(DefaultServerConnection.java:115)
      24. com.mongodb.operation.MixedBulkWriteOperation$Run$2.executeWriteCommandProtocol(MixedBulkWriteOperation.java:455)
      25. com.mongodb.operation.MixedBulkWriteOperation$Run$RunExecutor.execute(MixedBulkWriteOperation.java:646)
      26. com.mongodb.operation.MixedBulkWriteOperation$Run.execute(MixedBulkWriteOperation.java:401)
      27. com.mongodb.operation.MixedBulkWriteOperation$1.call(MixedBulkWriteOperation.java:179)
      28. com.mongodb.operation.MixedBulkWriteOperation$1.call(MixedBulkWriteOperation.java:168)
      28 frames