org.bson.codecs.configuration.CodecConfigurationException

tip

Current Spark-Mongodb does not support 3.x mongo drivers. Use long instead of Date until it is upgraded.

tip

Current Spark-Mongodb does not support 3.x mongo drivers. Use long instead of Date until it is upgraded.

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

  • I use {{com.mongodb.client.MongoCollection.aggregate(List<? extends Bson>)}} with an aggregation pipeline that contains {{$match}} directives. I build some of them with the {{com.mongodb.client.model.Filters}} class. When executing the aggregation I get an exception: {code} org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class com.mongodb.client.model.Filters$AndFilter. at org.bson.codecs.configuration.CodecCache.getOrThrow(CodecCache.java:46) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.configuration.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:63) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.configuration.ChildCodecRegistry.get(ChildCodecRegistry.java:51) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:174) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:189) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:131) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:45) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.EncoderContext.encodeWithChildContext(EncoderContext.java:91) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.BsonArrayCodec.encode(BsonArrayCodec.java:69) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.BsonArrayCodec.encode(BsonArrayCodec.java:36) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.EncoderContext.encodeWithChildContext(EncoderContext.java:91) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.BsonDocumentCodec.writeValue(BsonDocumentCodec.java:133) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.BsonDocumentCodec.encode(BsonDocumentCodec.java:112) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.BsonDocumentCodec.encode(BsonDocumentCodec.java:40) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.RequestMessage.addDocument(RequestMessage.java:216) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.RequestMessage.addDocument(RequestMessage.java:168) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.CommandMessage.encodeMessageBody(CommandMessage.java:69) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.RequestMessage.encode(RequestMessage.java:132) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.CommandProtocol.sendMessage(CommandProtocol.java:119) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.CommandProtocol.execute(CommandProtocol.java:84) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:155) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:219) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.DefaultServerConnection.command(DefaultServerConnection.java:146) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:182) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:166) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.operation.AggregateOperation$1.call(AggregateOperation.java:199) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.operation.AggregateOperation$1.call(AggregateOperation.java:196) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:195) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:168) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.operation.AggregateOperation.execute(AggregateOperation.java:196) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.operation.AggregateOperation.execute(AggregateOperation.java:62) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.Mongo.execute(Mongo.java:736) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.Mongo$2.execute(Mongo.java:723) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.OperationIterable.iterator(OperationIterable.java:47) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.AggregateIterableImpl.iterator(AggregateIterableImpl.java:92) ~[mongo-java-driver-3.0.0.jar:na] {code}
    via by Jochen Kemnade,
  • I use {{com.mongodb.client.MongoCollection.aggregate(List<? extends Bson>)}} with an aggregation pipeline that contains {{$match}} directives. I build some of them with the {{com.mongodb.client.model.Filters}} class. When executing the aggregation I get an exception: {code} org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class com.mongodb.client.model.Filters$AndFilter. at org.bson.codecs.configuration.CodecCache.getOrThrow(CodecCache.java:46) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.configuration.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:63) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.configuration.ChildCodecRegistry.get(ChildCodecRegistry.java:51) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:174) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:189) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:131) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:45) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.EncoderContext.encodeWithChildContext(EncoderContext.java:91) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.BsonArrayCodec.encode(BsonArrayCodec.java:69) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.BsonArrayCodec.encode(BsonArrayCodec.java:36) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.EncoderContext.encodeWithChildContext(EncoderContext.java:91) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.BsonDocumentCodec.writeValue(BsonDocumentCodec.java:133) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.BsonDocumentCodec.encode(BsonDocumentCodec.java:112) ~[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.BsonDocumentCodec.encode(BsonDocumentCodec.java:40) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.RequestMessage.addDocument(RequestMessage.java:216) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.RequestMessage.addDocument(RequestMessage.java:168) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.CommandMessage.encodeMessageBody(CommandMessage.java:69) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.RequestMessage.encode(RequestMessage.java:132) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.CommandProtocol.sendMessage(CommandProtocol.java:119) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.CommandProtocol.execute(CommandProtocol.java:84) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:155) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:219) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.DefaultServerConnection.command(DefaultServerConnection.java:146) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:182) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:166) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.operation.AggregateOperation$1.call(AggregateOperation.java:199) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.operation.AggregateOperation$1.call(AggregateOperation.java:196) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:195) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:168) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.operation.AggregateOperation.execute(AggregateOperation.java:196) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.operation.AggregateOperation.execute(AggregateOperation.java:62) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.Mongo.execute(Mongo.java:736) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.Mongo$2.execute(Mongo.java:723) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.OperationIterable.iterator(OperationIterable.java:47) ~[mongo-java-driver-3.0.0.jar:na] at com.mongodb.AggregateIterableImpl.iterator(AggregateIterableImpl.java:92) ~[mongo-java-driver-3.0.0.jar:na] {code}
    via by Jochen Kemnade,
  • 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}
    via by Emmanuel Bernard,
  • Mongo Document Archives - BlogoSfera
    via by Unknown author,
  • How to save java.sql.date object in mongodb?
    via Stack Overflow by usman
    ,
    • org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class com.mongodb.client.model.Filters$AndFilter. at org.bson.codecs.configuration.CodecCache.getOrThrow(CodecCache.java:46)[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.configuration.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:63)[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.configuration.ChildCodecRegistry.get(ChildCodecRegistry.java:51)[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:174)[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:189)[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:131)[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:45)[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63)[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29)[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.EncoderContext.encodeWithChildContext(EncoderContext.java:91)[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.BsonArrayCodec.encode(BsonArrayCodec.java:69)[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.BsonArrayCodec.encode(BsonArrayCodec.java:36)[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.EncoderContext.encodeWithChildContext(EncoderContext.java:91)[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.BsonDocumentCodec.writeValue(BsonDocumentCodec.java:133)[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.BsonDocumentCodec.encode(BsonDocumentCodec.java:112)[mongo-java-driver-3.0.0.jar:na] at org.bson.codecs.BsonDocumentCodec.encode(BsonDocumentCodec.java:40)[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.RequestMessage.addDocument(RequestMessage.java:216)[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.RequestMessage.addDocument(RequestMessage.java:168)[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.CommandMessage.encodeMessageBody(CommandMessage.java:69)[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.RequestMessage.encode(RequestMessage.java:132)[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.CommandProtocol.sendMessage(CommandProtocol.java:119)[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.CommandProtocol.execute(CommandProtocol.java:84)[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:155)[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:219)[mongo-java-driver-3.0.0.jar:na] at com.mongodb.connection.DefaultServerConnection.command(DefaultServerConnection.java:146)[mongo-java-driver-3.0.0.jar:na] at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:182)[mongo-java-driver-3.0.0.jar:na] at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:166)[mongo-java-driver-3.0.0.jar:na] at com.mongodb.operation.AggregateOperation$1.call(AggregateOperation.java:199)[mongo-java-driver-3.0.0.jar:na] at com.mongodb.operation.AggregateOperation$1.call(AggregateOperation.java:196)[mongo-java-driver-3.0.0.jar:na] at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:195)[mongo-java-driver-3.0.0.jar:na] at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:168)[mongo-java-driver-3.0.0.jar:na] at com.mongodb.operation.AggregateOperation.execute(AggregateOperation.java:196)[mongo-java-driver-3.0.0.jar:na] at com.mongodb.operation.AggregateOperation.execute(AggregateOperation.java:62)[mongo-java-driver-3.0.0.jar:na] at com.mongodb.Mongo.execute(Mongo.java:736)[mongo-java-driver-3.0.0.jar:na] at com.mongodb.Mongo$2.execute(Mongo.java:723)[mongo-java-driver-3.0.0.jar:na] at com.mongodb.OperationIterable.iterator(OperationIterable.java:47)[mongo-java-driver-3.0.0.jar:na] at com.mongodb.AggregateIterableImpl.iterator(AggregateIterableImpl.java:92)[mongo-java-driver-3.0.0.jar:na]

    Users with the same issue

    DunmerDunmer
    6 times, last one,
    Alireza MohamadiAlireza Mohamadi
    2 times, last one,
    rprp
    1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    31 more bugmates