org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class java.lang.Character.

JIRA | Emmanuel Bernard | 2 years ago
  1. 0

    In 2.x we could put a {{Character}} inside a field value. This is no longer the case in 3.0. {code} BasicDBObject object = ... object.put("delimiter", '/'); ... List<DBObject> objectsToInsert = new ArrayList<>(); objectsToInsert.add(object); DBCollection collection = ... collection.insert(objectsToInsert, WriteConcern.ACKNOWLEDGED); {code} Raises the following exception {code} org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class java.lang.Character. at org.bson.codecs.configuration.CodecCache.getOrThrow(CodecCache.java:46) at org.bson.codecs.configuration.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:63) at org.bson.codecs.configuration.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:37) at com.mongodb.DBObjectCodec.writeValue(DBObjectCodec.java:210) at com.mongodb.DBObjectCodec.encode(DBObjectCodec.java:128) at com.mongodb.DBObjectCodec.encode(DBObjectCodec.java:61) at com.mongodb.CompoundDBObjectCodec.encode(CompoundDBObjectCodec.java:48) at com.mongodb.CompoundDBObjectCodec.encode(CompoundDBObjectCodec.java:27) 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:99) at com.mongodb.connection.InsertCommandMessage.writeTheWrites(InsertCommandMessage.java:43) at com.mongodb.connection.BaseWriteCommandMessage.encodeMessageBody(BaseWriteCommandMessage.java:112) at com.mongodb.connection.BaseWriteCommandMessage.encodeMessageBody(BaseWriteCommandMessage.java:35) at com.mongodb.connection.RequestMessage.encode(RequestMessage.java:132) at com.mongodb.connection.BaseWriteCommandMessage.encode(BaseWriteCommandMessage.java:89) at com.mongodb.connection.WriteCommandProtocol.sendMessage(WriteCommandProtocol.java:170) at com.mongodb.connection.WriteCommandProtocol.execute(WriteCommandProtocol.java:73) at com.mongodb.connection.InsertCommandProtocol.execute(InsertCommandProtocol.java:66) at com.mongodb.connection.InsertCommandProtocol.execute(InsertCommandProtocol.java:37) at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:155) at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:219) at com.mongodb.connection.DefaultServerConnection.insertCommand(DefaultServerConnection.java:108) at com.mongodb.operation.InsertOperation.executeCommandProtocol(InsertOperation.java:76) at com.mongodb.operation.BaseWriteOperation$1.call(BaseWriteOperation.java:111) at com.mongodb.operation.BaseWriteOperation$1.call(BaseWriteOperation.java:106) at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:186) at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:177) at com.mongodb.operation.BaseWriteOperation.execute(BaseWriteOperation.java:106) at com.mongodb.operation.BaseWriteOperation.execute(BaseWriteOperation.java:58) at com.mongodb.Mongo.execute(Mongo.java:745) at com.mongodb.Mongo$2.execute(Mongo.java:728) at com.mongodb.DBCollection.executeWriteOperation(DBCollection.java:327) at com.mongodb.DBCollection.insert(DBCollection.java:323) at com.mongodb.DBCollection.insert(DBCollection.java:314) at com.mongodb.DBCollection.insert(DBCollection.java:284) at com.mongodb.DBCollection.insert(DBCollection.java:250) {code}

    JIRA | 2 years ago | Emmanuel Bernard
    org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class java.lang.Character.
  2. 0

    In 2.x we could put a {{Character}} inside a field value. This is no longer the case in 3.0. {code} BasicDBObject object = ... object.put("delimiter", '/'); ... List<DBObject> objectsToInsert = new ArrayList<>(); objectsToInsert.add(object); DBCollection collection = ... collection.insert(objectsToInsert, WriteConcern.ACKNOWLEDGED); {code} Raises the following exception {code} org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class java.lang.Character. at org.bson.codecs.configuration.CodecCache.getOrThrow(CodecCache.java:46) at org.bson.codecs.configuration.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:63) at org.bson.codecs.configuration.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:37) at com.mongodb.DBObjectCodec.writeValue(DBObjectCodec.java:210) at com.mongodb.DBObjectCodec.encode(DBObjectCodec.java:128) at com.mongodb.DBObjectCodec.encode(DBObjectCodec.java:61) at com.mongodb.CompoundDBObjectCodec.encode(CompoundDBObjectCodec.java:48) at com.mongodb.CompoundDBObjectCodec.encode(CompoundDBObjectCodec.java:27) 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:99) at com.mongodb.connection.InsertCommandMessage.writeTheWrites(InsertCommandMessage.java:43) at com.mongodb.connection.BaseWriteCommandMessage.encodeMessageBody(BaseWriteCommandMessage.java:112) at com.mongodb.connection.BaseWriteCommandMessage.encodeMessageBody(BaseWriteCommandMessage.java:35) at com.mongodb.connection.RequestMessage.encode(RequestMessage.java:132) at com.mongodb.connection.BaseWriteCommandMessage.encode(BaseWriteCommandMessage.java:89) at com.mongodb.connection.WriteCommandProtocol.sendMessage(WriteCommandProtocol.java:170) at com.mongodb.connection.WriteCommandProtocol.execute(WriteCommandProtocol.java:73) at com.mongodb.connection.InsertCommandProtocol.execute(InsertCommandProtocol.java:66) at com.mongodb.connection.InsertCommandProtocol.execute(InsertCommandProtocol.java:37) at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:155) at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:219) at com.mongodb.connection.DefaultServerConnection.insertCommand(DefaultServerConnection.java:108) at com.mongodb.operation.InsertOperation.executeCommandProtocol(InsertOperation.java:76) at com.mongodb.operation.BaseWriteOperation$1.call(BaseWriteOperation.java:111) at com.mongodb.operation.BaseWriteOperation$1.call(BaseWriteOperation.java:106) at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:186) at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:177) at com.mongodb.operation.BaseWriteOperation.execute(BaseWriteOperation.java:106) at com.mongodb.operation.BaseWriteOperation.execute(BaseWriteOperation.java:58) at com.mongodb.Mongo.execute(Mongo.java:745) at com.mongodb.Mongo$2.execute(Mongo.java:728) at com.mongodb.DBCollection.executeWriteOperation(DBCollection.java:327) at com.mongodb.DBCollection.insert(DBCollection.java:323) at com.mongodb.DBCollection.insert(DBCollection.java:314) at com.mongodb.DBCollection.insert(DBCollection.java:284) at com.mongodb.DBCollection.insert(DBCollection.java:250) {code}

    JIRA | 2 years ago | Emmanuel Bernard
    org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class java.lang.Character.
  3. 0

    Multithreaded tcp server and data storage into mongodb in java not working

    Stack Overflow | 11 months ago | Gerko Ford
    org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class java.net.Socket. at org.bson.codecs.configuration.CodecCache.getOrThrow (CodecCache.java:46)
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Custom MapOfValuesConverter for dealing with key values containg restricted characters (., $)

    Google Groups | 1 year ago | Tom
    org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class com.frequentis.ps.persistence.mongo.integration.model.pojo.model.ComplexValue.

    3 unregistered visitors
    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. org.bson.codecs.configuration.CodecConfigurationException

      Can't find a codec for class java.lang.Character.

      at org.bson.codecs.configuration.CodecCache.getOrThrow()
    2. MongoDB Java Driver
      DBCollection.insert
      1. org.bson.codecs.configuration.CodecCache.getOrThrow(CodecCache.java:46)
      2. org.bson.codecs.configuration.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:63)
      3. org.bson.codecs.configuration.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:37)
      4. com.mongodb.DBObjectCodec.writeValue(DBObjectCodec.java:210)
      5. com.mongodb.DBObjectCodec.encode(DBObjectCodec.java:128)
      6. com.mongodb.DBObjectCodec.encode(DBObjectCodec.java:61)
      7. com.mongodb.CompoundDBObjectCodec.encode(CompoundDBObjectCodec.java:48)
      8. com.mongodb.CompoundDBObjectCodec.encode(CompoundDBObjectCodec.java:27)
      9. org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63)
      10. org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29)
      11. com.mongodb.connection.InsertCommandMessage.writeTheWrites(InsertCommandMessage.java:99)
      12. com.mongodb.connection.InsertCommandMessage.writeTheWrites(InsertCommandMessage.java:43)
      13. com.mongodb.connection.BaseWriteCommandMessage.encodeMessageBody(BaseWriteCommandMessage.java:112)
      14. com.mongodb.connection.BaseWriteCommandMessage.encodeMessageBody(BaseWriteCommandMessage.java:35)
      15. com.mongodb.connection.RequestMessage.encode(RequestMessage.java:132)
      16. com.mongodb.connection.BaseWriteCommandMessage.encode(BaseWriteCommandMessage.java:89)
      17. com.mongodb.connection.WriteCommandProtocol.sendMessage(WriteCommandProtocol.java:170)
      18. com.mongodb.connection.WriteCommandProtocol.execute(WriteCommandProtocol.java:73)
      19. com.mongodb.connection.InsertCommandProtocol.execute(InsertCommandProtocol.java:66)
      20. com.mongodb.connection.InsertCommandProtocol.execute(InsertCommandProtocol.java:37)
      21. com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:155)
      22. com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:219)
      23. com.mongodb.connection.DefaultServerConnection.insertCommand(DefaultServerConnection.java:108)
      24. com.mongodb.operation.InsertOperation.executeCommandProtocol(InsertOperation.java:76)
      25. com.mongodb.operation.BaseWriteOperation$1.call(BaseWriteOperation.java:111)
      26. com.mongodb.operation.BaseWriteOperation$1.call(BaseWriteOperation.java:106)
      27. com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:186)
      28. com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:177)
      29. com.mongodb.operation.BaseWriteOperation.execute(BaseWriteOperation.java:106)
      30. com.mongodb.operation.BaseWriteOperation.execute(BaseWriteOperation.java:58)
      31. com.mongodb.Mongo.execute(Mongo.java:745)
      32. com.mongodb.Mongo$2.execute(Mongo.java:728)
      33. com.mongodb.DBCollection.executeWriteOperation(DBCollection.java:327)
      34. com.mongodb.DBCollection.insert(DBCollection.java:323)
      35. com.mongodb.DBCollection.insert(DBCollection.java:314)
      36. com.mongodb.DBCollection.insert(DBCollection.java:284)
      37. com.mongodb.DBCollection.insert(DBCollection.java:250)
      37 frames