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"
}
}
}
]
}
})
mongo-java-driver
add a comment |
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"
}
}
}
]
}
})
mongo-java-driver
add a comment |
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"
}
}
}
]
}
})
mongo-java-driver
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
mongo-java-driver
asked Nov 9 at 10:24
user988282
12614
12614
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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