Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.springframework.data.mapping.MappingException: Expected to read Document into type class org.bson.BsonValue but didn't find a PersistentEntity for the latter #4508

Closed
Leela-Kotte opened this issue Sep 15, 2023 · 6 comments

Comments

@Leela-Kotte
Copy link

Using ReactiveMongoTemplate with springboot parent 3.0.5, spring-cloud-dependencies 2022.0.1

public class ChangeStreamEventMetadata {

private BsonValue resumeToken;
private String target;
private Object raw;
private LocalDateTime createdTime;
private LocalDateTime updatedTime;

}

reactiveMongoTemplate.save(changeMetaData) is working good.

Here is the saved Record from DB.

{ "_id": { "$oid": "64fffd695953a59d0c6b5b7e" }, "target": "order", "createdTime": { "$date": "2023-09-12T05:55:38.724Z" }, "raw": { "resumeToken": { "_data": "8265004A8A000000012B022C01002B026E5A1004C91F7283EDD04FE1ABC8AE492DA4399046645F6964006465004A8237FFB3688026B01A0004" }, "namespaceDocument": { "db": "omsDB-qa1", "coll": "order" }, "fullDocument": { "_id": { "$oid": "65004a8237ffb3688026b01a" }, "orderId": "MHQ0369409148", "orderChannel": "Web", "orderOrigin": "MHQ", "orderType": "Local", "orderTimestamp": { "$date": "2023-09-12T11:24:41.000Z" }, "languageId": "en-US", "siteId": "mhq", "sendingMember": "12-0503AA", "codeList": {}, "promotionDetails": {}, "masterDB": "LINK", "testOrder": false, "createdDate": { "$date": "2023-09-12T11:24:50.120Z" }, "lastUpdatedDate": { "$date": "2023-09-12T11:24:59.001Z" }, "havingGiftNowItem": false, "_class": "com.ftd.oms.order.model.Order" }, "documentKey": { "_id": { "$oid": "65004a8237ffb3688026b01a" } }, "clusterTime": { "$timestamp": { "t": 1694517898, "i": 1 } }, "operationTypeString": "update", "operationType": "UPDATE", "updateDescription": { "removedFields": [], "updatedFields": { "lastUpdatedDate": { "$date": "2023-09-12T11:24:57.973Z" } }, "truncatedArrays": [] }, "txnNumber": { "$numberLong": "43" }, "lsid": { "id": { "$binary": { "base64": "/6F4apB8QgGXt3rmpPWFMQ==", "subType": "04" } }, "uid": { "$binary": { "base64": "FRUFc8gvQZ413DNLsqnAKSCD13ek35fBh55nTWzxKSs=", "subType": "00" } } }, "_class": "com.mongodb.client.model.changestream.ChangeStreamDocument" }, "resumeToken": { "_data": "8265004A8A000000012B022C01002B026E5A1004C91F7283EDD04FE1ABC8AE492DA4399046645F6964006465004A8237FFB3688026B01A0004" }, "updatedTime": { "$date": "2023-09-12T11:25:05.147Z" } }

But when I try to retrieve the above using find method (please find code snippet below), running into mappingException

reactiveMongoTemplate.findOne(query, ChangeStreamEventMetadata.class, "changeStreamEventMetadata");

org.springframework.data.mapping.MappingException: Expected to read Document Document{{_data=8265004A8A000000012B022C01002B026E5A1004C91F7283EDD04FE1ABC8AE492DA4399046645F6964006465004A8237FFB3688026B01A0004}} into type class org.bson.BsonValue but didn't find a PersistentEntity for the latter
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.readDocument(MappingMongoConverter.java:474)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter$DefaultConversionContext.convert(MappingMongoConverter.java:2354)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter$ConversionContext.convert(MappingMongoConverter.java:2160)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter$MongoDbPropertyValueProvider.getPropertyValue(MappingMongoConverter.java:1928)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.readProperties(MappingMongoConverter.java:624)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.populateProperties(MappingMongoConverter.java:535)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:513)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.readDocument(MappingMongoConverter.java:477)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:413)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:409)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:121)
at org.springframework.data.mongodb.core.ReactiveMongoTemplate$ReadDocumentCallback.doWith(ReactiveMongoTemplate.java:2907)
at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:132)
at com.ftd.commons.logging.config.MdcContextConfig$MdcContextLifter.onNext(MdcContextConfig.java:63)
at reactor.core.publisher.FluxHide$SuppressFuseableSubscriber.onNext(FluxHide.java:137)
at reactor.core.publisher.MonoFlatMap$FlatMapMain.secondComplete(MonoFlatMap.java:245)
at reactor.core.publisher.MonoFlatMap$FlatMapInner.onNext(MonoFlatMap.java:305)
at com.ftd.commons.logging.config.MdcContextConfig$MdcContextLifter.onNext(MdcContextConfig.java:63)
at reactor.core.publisher.MonoCreate$DefaultMonoSink.success(MonoCreate.java:172)
at com.mongodb.reactivestreams.client.internal.BatchCursorPublisher.lambda$first$0(BatchCursorPublisher.java:114)
at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onNext(MonoPeekTerminal.java:171)
at com.ftd.commons.logging.config.MdcContextConfig$MdcContextLifter.onNext(MdcContextConfig.java:63)
at reactor.core.publisher.FluxHide$SuppressFuseableSubscriber.onNext(FluxHide.java:137)
at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onNext(MonoPeekTerminal.java:180)
at com.ftd.commons.logging.config.MdcContextConfig$MdcContextLifter.onNext(MdcContextConfig.java:63)
at reactor.core.publisher.FluxHide$SuppressFuseableSubscriber.onNext(FluxHide.java:137)
at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onNext(MonoPeekTerminal.java:180)
at com.ftd.commons.logging.config.MdcContextConfig$MdcContextLifter.onNext(MdcContextConfig.java:63)
at reactor.core.publisher.MonoCreate$DefaultMonoSink.success(MonoCreate.java:172)
at com.mongodb.reactivestreams.client.internal.MongoOperationPublisher.lambda$sinkToCallback$31(MongoOperationPublisher.java:577)
at com.mongodb.internal.operation.AsyncQueryBatchCursor.next(AsyncQueryBatchCursor.java:173)
at com.mongodb.reactivestreams.client.internal.BatchCursor.lambda$next$0(BatchCursor.java:38)
at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:58)
at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
at reactor.core.publisher.MonoContextWriteRestoringThreadLocals.subscribe(MonoContextWriteRestoringThreadLocals.java:45)
at reactor.core.publisher.Mono.subscribe(Mono.java:4485)
at reactor.core.publisher.Mono.subscribeWith(Mono.java:4551)
at reactor.core.publisher.Mono.subscribe(Mono.java:4313)
at com.mongodb.reactivestreams.client.internal.BatchCursorPublisher.lambda$first$1(BatchCursorPublisher.java:118)
at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:58)
at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:165)
at com.ftd.commons.logging.config.MdcContextConfig$MdcContextLifter.onNext(MdcContextConfig.java:63)
at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:122)
at com.ftd.commons.logging.config.MdcContextConfig$MdcContextLifter.onNext(MdcContextConfig.java:63)
at reactor.core.publisher.MonoNext$NextSubscriber.onNext(MonoNext.java:82)
at reactor.core.publisher.MonoNext$NextSubscriber.onNext(MonoNext.java:82)
at com.ftd.commons.logging.config.MdcContextConfig$MdcContextLifter.onNext(MdcContextConfig.java:63)
at reactor.core.publisher.MonoFlatMap$FlatMapMain.secondComplete(MonoFlatMap.java:245)
at reactor.core.publisher.MonoFlatMap$FlatMapInner.onNext(MonoFlatMap.java:305)
at com.ftd.commons.logging.config.MdcContextConfig$MdcContextLifter.onNext(MdcContextConfig.java:63)
at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onNext(MonoPeekTerminal.java:180)
at com.ftd.commons.logging.config.MdcContextConfig$MdcContextLifter.onNext(MdcContextConfig.java:63)
at reactor.core.publisher.MonoCreate$DefaultMonoSink.success(MonoCreate.java:172)
at com.mongodb.reactivestreams.client.internal.MongoOperationPublisher.lambda$sinkToCallback$31(MongoOperationPublisher.java:577)
at com.mongodb.reactivestreams.client.internal.OperationExecutorImpl.lambda$execute$2(OperationExecutorImpl.java:94)
at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:46)
at com.mongodb.internal.async.function.AsyncCallbackSupplier.lambda$whenComplete$1(AsyncCallbackSupplier.java:97)
at com.mongodb.internal.async.function.RetryingAsyncCallbackSupplier$RetryingCallback.onResult(RetryingAsyncCallbackSupplier.java:116)
at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:46)
at com.mongodb.internal.async.function.AsyncCallbackSupplier.lambda$whenComplete$1(AsyncCallbackSupplier.java:97)
at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:46)
at com.mongodb.internal.async.function.AsyncCallbackSupplier.lambda$whenComplete$1(AsyncCallbackSupplier.java:97)
at com.mongodb.internal.operation.FindOperation$1.onResult(FindOperation.java:379)
at com.mongodb.internal.operation.CommandOperationHelper.lambda$transformingReadCallback$10(CommandOperationHelper.java:332)
at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:46)
at com.mongodb.internal.connection.DefaultServer$DefaultServerProtocolExecutor$1.onResult(DefaultServer.java:242)
at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:46)
at com.mongodb.internal.connection.CommandProtocolImpl$1.onResult(CommandProtocolImpl.java:84)
at com.mongodb.internal.connection.DefaultConnectionPool$PooledConnection$1.onResult(DefaultConnectionPool.java:683)
at com.mongodb.internal.connection.UsageTrackingInternalConnection$2.onResult(UsageTrackingInternalConnection.java:159)
at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:46)
at com.mongodb.internal.connection.InternalStreamConnection$2$1.onResult(InternalStreamConnection.java:524)
at com.mongodb.internal.connection.InternalStreamConnection$2$1.onResult(InternalStreamConnection.java:501)
at com.mongodb.internal.connection.InternalStreamConnection$MessageHeaderCallback$MessageCallback.onResult(InternalStreamConnection.java:824)
at com.mongodb.internal.connection.InternalStreamConnection$MessageHeaderCallback$MessageCallback.onResult(InternalStreamConnection.java:788)
at com.mongodb.internal.connection.InternalStreamConnection$5.completed(InternalStreamConnection.java:648)
at com.mongodb.internal.connection.InternalStreamConnection$5.completed(InternalStreamConnection.java:645)
at com.mongodb.connection.netty.NettyStream.readAsync(NettyStream.java:319)
at com.mongodb.connection.netty.NettyStream.readAsync(NettyStream.java:266)
at com.mongodb.internal.connection.InternalStreamConnection.readAsync(InternalStreamConnection.java:645)
at com.mongodb.internal.connection.InternalStreamConnection.access$600(InternalStreamConnection.java:89)
at com.mongodb.internal.connection.InternalStreamConnection$MessageHeaderCallback.onResult(InternalStreamConnection.java:778)
at com.mongodb.internal.connection.InternalStreamConnection$MessageHeaderCallback.onResult(InternalStreamConnection.java:763)
at com.mongodb.internal.connection.InternalStreamConnection$5.completed(InternalStreamConnection.java:648)
at com.mongodb.internal.connection.InternalStreamConnection$5.completed(InternalStreamConnection.java:645)
at com.mongodb.connection.netty.NettyStream.readAsync(NettyStream.java:319)
at com.mongodb.connection.netty.NettyStream.handleReadResponse(NettyStream.java:347)
at com.mongodb.connection.netty.NettyStream.access$1100(NettyStream.java:105)
at com.mongodb.connection.netty.NettyStream$InboundBufferHandler.channelRead0(NettyStream.java:421)
at com.mongodb.connection.netty.NettyStream$InboundBufferHandler.channelRead0(NettyStream.java:418)
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1382)
at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1245)
at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1294)
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:529)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:468)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 15, 2023
@christophstrobl
Copy link
Member

Thank you or reporting, to help us triage the issue please take the time to provide a complete minimal sample (something that we can unzip or git clone, build, and deploy) that reproduces the problem.

@christophstrobl christophstrobl added status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 18, 2023
@Leela-Kotte
Copy link
Author

Leela-Kotte commented Sep 18, 2023

Thanks for the response. @christophstrobl
You can clone the sample from here https://github.com/Leela-Kotte/MongoChangeStream Hope this helps.

As mentioned, you will notice the issue when you try fetching the saved changeStreamEventMetadata from DB.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Sep 18, 2023
@Leela-Kotte
Copy link
Author

Do you have any update on the issue?

@christophstrobl
Copy link
Member

@Leela-Kotte I'm sorry but the sample is neither minimal nor simple. Please take the time to condense it to the smallest possible unit (like a failing test) that is required to reproduce the issue.

@christophstrobl christophstrobl added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Oct 9, 2023
@spring-projects-issues
Copy link

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Oct 16, 2023
@spring-projects-issues
Copy link

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

@spring-projects-issues spring-projects-issues closed this as not planned Won't fix, can't repro, duplicate, stale Oct 23, 2023
@spring-projects-issues spring-projects-issues removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue labels Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants