CodecConfigurationException in mongo-java-driver when using $elemMatch in $all











up vote
0
down vote

favorite












Who has the same error and how to fix it?



Java code:



// For simplify code I left one criteria elemMatch in all criteria.
Criteria expectedCriteria = Criteria.where("tags").all(new Criteria().elemMatch(Criteria.where("localization").is("EN")));
String json = expectedCriteria.getCriteriaObject().toJson();


Exception:



Exception in thread "main" org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class org.springframework.data.mongodb.core.query.Criteria.
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 org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:184)
at org.bson.codecs.DocumentCodec.writeIterable(DocumentCodec.java:207)
at org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:180)
at org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:199)
at org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:182)
at org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:199)
at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:141)
at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:45)
at org.bson.Document.toJson(Document.java:313)
at org.bson.Document.toJson(Document.java:286)
at org.bson.Document.toJson(Document.java:273)


Documentation:
https://docs.mongodb.com/manual/reference/operator/query/all/#use-all-with-elemmatch



Version of mongo-java-driver in reproduce:
(in all)
- 3.4.3
- 3.5.0
- 3.6.4
- 3.7.1
- 3.8.2
- 3.9.0



Mongo DB script which works for code:



db.getCollection('devices').find({ 
"tags": {
"$all": [{
"$elemMatch": {
"key": "localization",
"value": {
"$eq": "EN"
}
}
}
]
}
})









share|improve this question


























    up vote
    0
    down vote

    favorite












    Who has the same error and how to fix it?



    Java code:



    // For simplify code I left one criteria elemMatch in all criteria.
    Criteria expectedCriteria = Criteria.where("tags").all(new Criteria().elemMatch(Criteria.where("localization").is("EN")));
    String json = expectedCriteria.getCriteriaObject().toJson();


    Exception:



    Exception in thread "main" org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class org.springframework.data.mongodb.core.query.Criteria.
    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 org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:184)
    at org.bson.codecs.DocumentCodec.writeIterable(DocumentCodec.java:207)
    at org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:180)
    at org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:199)
    at org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:182)
    at org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:199)
    at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:141)
    at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:45)
    at org.bson.Document.toJson(Document.java:313)
    at org.bson.Document.toJson(Document.java:286)
    at org.bson.Document.toJson(Document.java:273)


    Documentation:
    https://docs.mongodb.com/manual/reference/operator/query/all/#use-all-with-elemmatch



    Version of mongo-java-driver in reproduce:
    (in all)
    - 3.4.3
    - 3.5.0
    - 3.6.4
    - 3.7.1
    - 3.8.2
    - 3.9.0



    Mongo DB script which works for code:



    db.getCollection('devices').find({ 
    "tags": {
    "$all": [{
    "$elemMatch": {
    "key": "localization",
    "value": {
    "$eq": "EN"
    }
    }
    }
    ]
    }
    })









    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Who has the same error and how to fix it?



      Java code:



      // For simplify code I left one criteria elemMatch in all criteria.
      Criteria expectedCriteria = Criteria.where("tags").all(new Criteria().elemMatch(Criteria.where("localization").is("EN")));
      String json = expectedCriteria.getCriteriaObject().toJson();


      Exception:



      Exception in thread "main" org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class org.springframework.data.mongodb.core.query.Criteria.
      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 org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:184)
      at org.bson.codecs.DocumentCodec.writeIterable(DocumentCodec.java:207)
      at org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:180)
      at org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:199)
      at org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:182)
      at org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:199)
      at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:141)
      at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:45)
      at org.bson.Document.toJson(Document.java:313)
      at org.bson.Document.toJson(Document.java:286)
      at org.bson.Document.toJson(Document.java:273)


      Documentation:
      https://docs.mongodb.com/manual/reference/operator/query/all/#use-all-with-elemmatch



      Version of mongo-java-driver in reproduce:
      (in all)
      - 3.4.3
      - 3.5.0
      - 3.6.4
      - 3.7.1
      - 3.8.2
      - 3.9.0



      Mongo DB script which works for code:



      db.getCollection('devices').find({ 
      "tags": {
      "$all": [{
      "$elemMatch": {
      "key": "localization",
      "value": {
      "$eq": "EN"
      }
      }
      }
      ]
      }
      })









      share|improve this question













      Who has the same error and how to fix it?



      Java code:



      // For simplify code I left one criteria elemMatch in all criteria.
      Criteria expectedCriteria = Criteria.where("tags").all(new Criteria().elemMatch(Criteria.where("localization").is("EN")));
      String json = expectedCriteria.getCriteriaObject().toJson();


      Exception:



      Exception in thread "main" org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class org.springframework.data.mongodb.core.query.Criteria.
      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 org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:184)
      at org.bson.codecs.DocumentCodec.writeIterable(DocumentCodec.java:207)
      at org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:180)
      at org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:199)
      at org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:182)
      at org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:199)
      at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:141)
      at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:45)
      at org.bson.Document.toJson(Document.java:313)
      at org.bson.Document.toJson(Document.java:286)
      at org.bson.Document.toJson(Document.java:273)


      Documentation:
      https://docs.mongodb.com/manual/reference/operator/query/all/#use-all-with-elemmatch



      Version of mongo-java-driver in reproduce:
      (in all)
      - 3.4.3
      - 3.5.0
      - 3.6.4
      - 3.7.1
      - 3.8.2
      - 3.9.0



      Mongo DB script which works for code:



      db.getCollection('devices').find({ 
      "tags": {
      "$all": [{
      "$elemMatch": {
      "key": "localization",
      "value": {
      "$eq": "EN"
      }
      }
      }
      ]
      }
      })






      mongo-java-driver






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 9 at 10:24









      user988282

      12614




      12614





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53223909%2fcodecconfigurationexception-in-mongo-java-driver-when-using-elemmatch-in-all%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53223909%2fcodecconfigurationexception-in-mongo-java-driver-when-using-elemmatch-in-all%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Landwehr

          Reims

          Schenkenzell