org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class com.mongodb.client.model.Filters$AndFilter.

JIRA | Jochen Kemnade | 2 years ago
  1. 0

    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}

    JIRA | 2 years ago | Jochen Kemnade
    org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class com.mongodb.client.model.Filters$AndFilter.
  2. 0

    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}

    JIRA | 2 years ago | Jochen Kemnade
    org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class com.mongodb.client.model.Filters$AndFilter.
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 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.
  5. 0
    Current Spark-Mongodb does not support 3.x mongo drivers. Use long instead of Date until it is upgraded.

    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 com.mongodb.client.model.Filters$AndFilter.

      at org.bson.codecs.configuration.CodecCache.getOrThrow()
    2. MongoDB Java Driver
      AggregateIterableImpl.iterator
      1. org.bson.codecs.configuration.CodecCache.getOrThrow(CodecCache.java:46)[mongo-java-driver-3.0.0.jar:na]
      2. org.bson.codecs.configuration.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:63)[mongo-java-driver-3.0.0.jar:na]
      3. org.bson.codecs.configuration.ChildCodecRegistry.get(ChildCodecRegistry.java:51)[mongo-java-driver-3.0.0.jar:na]
      4. org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:174)[mongo-java-driver-3.0.0.jar:na]
      5. org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:189)[mongo-java-driver-3.0.0.jar:na]
      6. org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:131)[mongo-java-driver-3.0.0.jar:na]
      7. org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:45)[mongo-java-driver-3.0.0.jar:na]
      8. org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63)[mongo-java-driver-3.0.0.jar:na]
      9. org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29)[mongo-java-driver-3.0.0.jar:na]
      10. org.bson.codecs.EncoderContext.encodeWithChildContext(EncoderContext.java:91)[mongo-java-driver-3.0.0.jar:na]
      11. org.bson.codecs.BsonArrayCodec.encode(BsonArrayCodec.java:69)[mongo-java-driver-3.0.0.jar:na]
      12. org.bson.codecs.BsonArrayCodec.encode(BsonArrayCodec.java:36)[mongo-java-driver-3.0.0.jar:na]
      13. org.bson.codecs.EncoderContext.encodeWithChildContext(EncoderContext.java:91)[mongo-java-driver-3.0.0.jar:na]
      14. org.bson.codecs.BsonDocumentCodec.writeValue(BsonDocumentCodec.java:133)[mongo-java-driver-3.0.0.jar:na]
      15. org.bson.codecs.BsonDocumentCodec.encode(BsonDocumentCodec.java:112)[mongo-java-driver-3.0.0.jar:na]
      16. org.bson.codecs.BsonDocumentCodec.encode(BsonDocumentCodec.java:40)[mongo-java-driver-3.0.0.jar:na]
      17. com.mongodb.connection.RequestMessage.addDocument(RequestMessage.java:216)[mongo-java-driver-3.0.0.jar:na]
      18. com.mongodb.connection.RequestMessage.addDocument(RequestMessage.java:168)[mongo-java-driver-3.0.0.jar:na]
      19. com.mongodb.connection.CommandMessage.encodeMessageBody(CommandMessage.java:69)[mongo-java-driver-3.0.0.jar:na]
      20. com.mongodb.connection.RequestMessage.encode(RequestMessage.java:132)[mongo-java-driver-3.0.0.jar:na]
      21. com.mongodb.connection.CommandProtocol.sendMessage(CommandProtocol.java:119)[mongo-java-driver-3.0.0.jar:na]
      22. com.mongodb.connection.CommandProtocol.execute(CommandProtocol.java:84)[mongo-java-driver-3.0.0.jar:na]
      23. com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:155)[mongo-java-driver-3.0.0.jar:na]
      24. com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:219)[mongo-java-driver-3.0.0.jar:na]
      25. com.mongodb.connection.DefaultServerConnection.command(DefaultServerConnection.java:146)[mongo-java-driver-3.0.0.jar:na]
      26. com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:182)[mongo-java-driver-3.0.0.jar:na]
      27. com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:166)[mongo-java-driver-3.0.0.jar:na]
      28. com.mongodb.operation.AggregateOperation$1.call(AggregateOperation.java:199)[mongo-java-driver-3.0.0.jar:na]
      29. com.mongodb.operation.AggregateOperation$1.call(AggregateOperation.java:196)[mongo-java-driver-3.0.0.jar:na]
      30. com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:195)[mongo-java-driver-3.0.0.jar:na]
      31. com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:168)[mongo-java-driver-3.0.0.jar:na]
      32. com.mongodb.operation.AggregateOperation.execute(AggregateOperation.java:196)[mongo-java-driver-3.0.0.jar:na]
      33. com.mongodb.operation.AggregateOperation.execute(AggregateOperation.java:62)[mongo-java-driver-3.0.0.jar:na]
      34. com.mongodb.Mongo.execute(Mongo.java:736)[mongo-java-driver-3.0.0.jar:na]
      35. com.mongodb.Mongo$2.execute(Mongo.java:723)[mongo-java-driver-3.0.0.jar:na]
      36. com.mongodb.OperationIterable.iterator(OperationIterable.java:47)[mongo-java-driver-3.0.0.jar:na]
      37. com.mongodb.AggregateIterableImpl.iterator(AggregateIterableImpl.java:92)[mongo-java-driver-3.0.0.jar:na]
      37 frames