-
Type: Task
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.4.0
-
Component/s: Builders
-
Labels:None
Hi. I have the following code:
FindIterable<Document> it = posts.find( new Document("$or", (new Document("$not", (new Document("$elemMatch", eq("userID", userID))) ) .append( "views", new Document( "$elemMatch", new Document("$and", new Document("$eq", new Document ("userID", userID ) ).append ("$lt", new Document( "time", System .currentTimeMillis() - TimeUnit.DAYS .toMillis( 2) ) ) ) ) )) )); it.batchCursor((r, t) -> { if (t != null) { asyncFailed(t); } else { asyncCompleted(new AbstractMap .SimpleEntry<AsyncBatchCursor<Document>, Long>(r, System .currentTimeMillis() )); } });
And I get this exception:
org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class com.mongodb.client.model.Filters$SimpleEncodingFilter. 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.ChildCodecRegistry.get(ChildCodecRegistry.java:51) at org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:174) at org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:189) at org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:172) at org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:189) at org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:172) at org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:189) at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:131) at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:45) at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63) at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29) at org.bson.codecs.EncoderContext.encodeWithChildContext(EncoderContext.java:91) at org.bson.codecs.BsonDocumentCodec.writeValue(BsonDocumentCodec.java:136) at org.bson.codecs.BsonDocumentCodec.encode(BsonDocumentCodec.java:115) at org.bson.codecs.BsonDocumentCodec.encode(BsonDocumentCodec.java:41) at com.mongodb.connection.RequestMessage.addDocument(RequestMessage.java:253) at com.mongodb.connection.RequestMessage.addDocument(RequestMessage.java:205) at com.mongodb.connection.CommandMessage.encodeMessageBodyWithMetadata(CommandMessage.java:75) at com.mongodb.connection.RequestMessage.encodeWithMetadata(RequestMessage.java:160) at com.mongodb.connection.ProtocolHelper.encodeMessageWithMetadata(ProtocolHelper.java:156) at com.mongodb.connection.CommandProtocol.executeAsync(CommandProtocol.java:158) at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.executeAsync(DefaultServer.java:179) at com.mongodb.connection.DefaultServerConnection.executeProtocolAsync(DefaultServerConnection.java:295) at com.mongodb.connection.DefaultServerConnection.commandAsync(DefaultServerConnection.java:184) at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocolAsync(CommandOperationHelper.java:376) at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocolAsync(CommandOperationHelper.java:366) at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocolAsync(CommandOperationHelper.java:272) at com.mongodb.operation.FindOperation$2$1.call(FindOperation.java:564) at com.mongodb.operation.OperationHelper$7.call(OperationHelper.java:267) at com.mongodb.operation.OperationHelper.validateCollation(OperationHelper.java:128) at com.mongodb.operation.OperationHelper$6.call(OperationHelper.java:255) at com.mongodb.operation.OperationHelper.validateReadConcern(OperationHelper.java:91) at com.mongodb.operation.OperationHelper.validateReadConcernAndCollation(OperationHelper.java:249) at com.mongodb.operation.OperationHelper.validateReadConcernAndCollation(OperationHelper.java:264) at com.mongodb.operation.FindOperation$2.call(FindOperation.java:556) at com.mongodb.operation.OperationHelper$9.onResult(OperationHelper.java:482) at com.mongodb.operation.OperationHelper$9.onResult(OperationHelper.java:479) at com.mongodb.connection.DefaultServer$1.onResult(DefaultServer.java:105) at com.mongodb.connection.DefaultServer$1.onResult(DefaultServer.java:96) at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:49) at com.mongodb.connection.DefaultConnectionPool.openAsync(DefaultConnectionPool.java:188) at com.mongodb.connection.DefaultConnectionPool.getAsync(DefaultConnectionPool.java:145) at com.mongodb.connection.DefaultServer.getConnectionAsync(DefaultServer.java:96) at com.mongodb.binding.AsyncClusterBinding$AsyncClusterBindingConnectionSource.getConnection(AsyncClusterBinding.java:102) at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:479) at com.mongodb.operation.OperationHelper.access$100(OperationHelper.java:58) at com.mongodb.operation.OperationHelper$AsyncCallableWithConnectionAndSourceCallback.onResult(OperationHelper.java:499) at com.mongodb.operation.OperationHelper$AsyncCallableWithConnectionAndSourceCallback.onResult(OperationHelper.java:487) at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:49) at com.mongodb.binding.AsyncClusterBinding$1.onResult(AsyncClusterBinding.java:81) at com.mongodb.binding.AsyncClusterBinding$1.onResult(AsyncClusterBinding.java:75) at com.mongodb.connection.BaseCluster$ServerSelectionRequest.onResult(BaseCluster.java:409) at com.mongodb.connection.BaseCluster.handleServerSelectionRequest(BaseCluster.java:280) at com.mongodb.connection.BaseCluster.selectServerAsync(BaseCluster.java:141) at com.mongodb.binding.AsyncClusterBinding.getAsyncClusterBindingConnectionSource(AsyncClusterBinding.java:75) at com.mongodb.binding.AsyncClusterBinding.getReadConnectionSource(AsyncClusterBinding.java:65) at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:446) at com.mongodb.operation.FindOperation.executeAsync(FindOperation.java:546) at com.mongodb.async.client.MongoClientImpl$2.execute(MongoClientImpl.java:123) at com.mongodb.async.client.OperationIterable.batchCursor(OperationIterable.java:132) at com.mongodb.async.client.FindIterableImpl.batchCursor(FindIterableImpl.java:180) at com.sunova.bot.MongoDBDriver$6.requestAsync(MongoDBDriver.java:315) at co.paralleluniverse.fibers.FiberAsync$1.run(FiberAsync.java:127) at co.paralleluniverse.fibers.Fiber.exec(Fiber.java:803) at co.paralleluniverse.fibers.FiberForkJoinScheduler$FiberForkJoinTask.exec1(FiberForkJoinScheduler.java:266) at co.paralleluniverse.concurrent.forkjoin.ParkableForkJoinTask.doExec(ParkableForkJoinTask.java:117) at co.paralleluniverse.concurrent.forkjoin.ParkableForkJoinTask.exec(ParkableForkJoinTask.java:74) at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Which is thrown on
it.batchCursor((r, t) ->
line. What is wrong can you tell me please? I was using Filters and though maybe problem is because of using them, so switched to plain document style, but the problem still persists.