[JAVA-3945] Codec Configuration Exception When POJO has Field set as (fluent = true) Created: 19/Jan/21  Updated: 27/Oct/23  Resolved: 05/Feb/21

Status: Closed
Project: Java Driver
Component/s: POJO
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Kunal jani Assignee: Ross Lawley
Resolution: Gone away Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Java reactivestreams driver



 Description   

While declaring POJO classes with the codec registry configuration having the value of the automatic variable set to true, When the @Accessor(fluent = false) annotation is used, the converting a BSON document to a POJO using the aggregate(List<> Pipeline) successfully converts the MongoDB collection to a POJO. However, when the annotation @Accessor(fluent = true) is used with the POJO class, then a CodecConfigurationException is thrown. Can anyone please help me with this problem?



 Comments   
Comment by Backlog - Core Eng Program Management Team [ 05/Feb/21 ]

There hasn't been any recent activity on this ticket, so we're resolving it. Thanks for reaching out! Please feel free to comment on this if you're able to provide more information.

Comment by Ross Lawley [ 21/Jan/21 ]

Hi kunaljani18@gmail.com,

There's not much to go on from your comment. The error is reporting Can't find a codec for class com.snapcheck.db.reactive.entities.ActorDetail but the provided code doesn't include any details of the ActorDetail class.

Just to note the PojoCodec itself doesn't use the @Accessor annotation so I'm unclear how it relates to the PojoCodec or the issue you are seeing.

It would be great if you could provide some more detail.

Ross

Comment by Kunal jani [ 19/Jan/21 ]

@Data
@Accessors(fluent = true)
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class ClassName{}

 

org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class com.snapcheck.db.reactive.entities.ClassName.org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class com.snapcheck.db.reactive.entities.ActorDetails. at org.bson.internal.CodecCache.getOrThrow(CodecCache.java:57) at org.bson.internal.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:64) at org.bson.internal.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:39) at com.mongodb.internal.operation.Operations.aggregate(Operations.java:200) at com.mongodb.internal.operation.AsyncOperations.aggregate(AsyncOperations.java:129) at com.mongodb.async.client.AggregateIterableImpl.asAsyncReadOperation(AggregateIterableImpl.java:172) at com.mongodb.async.client.MongoIterableImpl.batchCursor(MongoIterableImpl.java:167) at com.mongodb.async.client.MongoIterableSubscription.requestInitialData(MongoIterableSubscription.java:46) at com.mongodb.async.client.AbstractSubscription.tryRequestInitialData(AbstractSubscription.java:164) at com.mongodb.async.client.AbstractSubscription.request(AbstractSubscription.java:87) at com.mongodb.reactivestreams.client.internal.ObservableToPublisher$1$1.request(ObservableToPublisher.java:48) at reactor.core.publisher.MonoNext$NextSubscriber.request(MonoNext.java:102) at reactor.core.publisher.MonoNext$NextSubscriber.request(MonoNext.java:102) at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:2152) at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onSubscribe(Operators.java:2026) at reactor.core.publisher.MonoNext$NextSubscriber.onSubscribe(MonoNext.java:64) at reactor.core.publisher.MonoNext$NextSubscriber.onSubscribe(MonoNext.java:64) at com.mongodb.reactivestreams.client.internal.ObservableToPublisher$1.onSubscribe(ObservableToPublisher.java:37) at com.mongodb.async.client.MongoIterableSubscription.<init>(MongoIterableSubscription.java:40) at com.mongodb.async.client.Observables$1.subscribe(Observables.java:47) at com.mongodb.reactivestreams.client.internal.ObservableToPublisher.subscribe(ObservableToPublisher.java:34) at com.mongodb.reactivestreams.client.internal.AggregatePublisherImpl.subscribe(AggregatePublisherImpl.java:121) at reactor.core.publisher.MonoFromPublisher.subscribe(MonoFromPublisher.java:63) at reactor.core.publisher.Mono.subscribe(Mono.java:4219) at reactor.core.publisher.Mono.subscribeWith(Mono.java:4330) at reactor.core.publisher.Mono.subscribe(Mono.java:4190) at reactor.core.publisher.Mono.subscribe(Mono.java:4126) at reactor.core.publisher.Mono.subscribe(Mono.java:4073) at com.snapcheck.db.reactive.ClassReactiveDAO.actorData(ClassReactiveDAO.java:124) at com.reactive.ClassTest.junitTest(ClassTest.java:124) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at io.vertx.ext.unit.junit.VertxUnitRunner.invokeTestMethod(VertxUnitRunner.java:95) at io.vertx.ext.unit.junit.VertxUnitRunner.lambda$invokeExplosively$0(VertxUnitRunner.java:114) at io.vertx.ext.unit.impl.TestContextImpl.run(TestContextImpl.java:90) at io.vertx.ext.unit.junit.VertxUnitRunner.invokeExplosively(VertxUnitRunner.java:130) at io.vertx.ext.unit.junit.VertxUnitRunner.access$000(VertxUnitRunner.java:39) at io.vertx.ext.unit.junit.VertxUnitRunner$1.evaluate(VertxUnitRunner.java:84) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at io.vertx.ext.unit.junit.VertxUnitRunner$2.evaluate(VertxUnitRunner.java:196) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:106) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:66) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:155) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:137) at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) at java.lang.Thread.run(Thread.java:748)

Comment by Ross Lawley [ 19/Jan/21 ]

Hi Kunal jani,

Many thanks for the ticket. Could you provide more detail on the bug? Either a full stacktrace or a test case to reproduce the error. Ideally, a minimal reproducible example would help as I could replicate the bug and use it as a test case for the fix.

Did you know the best place for asking questions is our MongoDB community portal, located here?

All the best,

Ross

Generated at Thu Feb 08 09:00:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.