-
Type: Question
-
Resolution: Won't Fix
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: POJO
-
None
Summary
ZonedDateTime failure while reading data from mongo.
https://github.com/MorphiaOrg/morphia/issues/1922 (Discussion details available here)
MongoDB: 4.2
Mongo Driver: 3.11.2
Morphia:2.2.3
How to Reproduce
Create Mongo Entity with ZonedDateTime field with it.
Try to save ZonedDatetime as String and then read it back from Database.
Exception:
org.bson.codecs.configuration.CodecConfigurationException: An exception occurred when decoding using the AutomaticPojoCodec. Decoding into a 'ZonedDateTime' failed with the following exception: Cannot find a public constructor for 'ZonedDateTime'. A custom Codec or PojoCodec may need to be explicitly configured and registered to handle this type. at org.bson.codecs.pojo.AutomaticPojoCodec.decode(AutomaticPojoCodec.java:40) at org.bson.codecs.DecoderContext.decodeWithChildContext(DecoderContext.java:96) at dev.morphia.mapping.codec.pojo.EntityDecoder.decodeModel(EntityDecoder.java:59) at dev.morphia.mapping.codec.pojo.EntityDecoder.decodeProperties(EntityDecoder.java:80) at dev.morphia.mapping.codec.pojo.EntityDecoder.decode(EntityDecoder.java:35) at dev.morphia.mapping.codec.pojo.MorphiaCodec.decode(MorphiaCodec.java:71) at dev.morphia.mapping.codec.pojo.EntityDecoder.decode(EntityDecoder.java:40) at dev.morphia.mapping.codec.pojo.MorphiaCodec.decode(MorphiaCodec.java:71) at com.mongodb.internal.operation.CommandResultArrayCodec.decode(CommandResultArrayCodec.java:52) at com.mongodb.internal.operation.CommandResultDocumentCodec.readValue(CommandResultDocumentCodec.java:60) at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:87) at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:42) at org.bson.internal.LazyCodec.decode(LazyCodec.java:48) at org.bson.codecs.BsonDocumentCodec.readValue(BsonDocumentCodec.java:104) at com.mongodb.internal.operation.CommandResultDocumentCodec.readValue(CommandResultDocumentCodec.java:63) at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:87) at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:42) at com.mongodb.internal.connection.ReplyMessage.<init>(ReplyMessage.java:51) at com.mongodb.internal.connection.InternalStreamConnection.getCommandResult(InternalStreamConnection.java:540) at com.mongodb.internal.connection.InternalStreamConnection.receiveCommandMessageResponse(InternalStreamConnection.java:425) at com.mongodb.internal.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:342) at com.mongodb.internal.connection.UsageTrackingInternalConnection.sendAndReceive(UsageTrackingInternalConnection.java:116) at com.mongodb.internal.connection.DefaultConnectionPool$PooledConnection.sendAndReceive(DefaultConnectionPool.java:647) at com.mongodb.internal.connection.CommandProtocolImpl.execute(CommandProtocolImpl.java:71) at com.mongodb.internal.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:244) at com.mongodb.internal.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:227) at com.mongodb.internal.connection.DefaultServerConnection.command(DefaultServerConnection.java:127) at com.mongodb.internal.connection.DefaultServerConnection.command(DefaultServerConnection.java:117) at com.mongodb.internal.connection.DefaultServer$OperationCountTrackingConnection.command(DefaultServer.java:348) at com.mongodb.internal.operation.CommandOperationHelper.createReadCommandAndExecute(CommandOperationHelper.java:228) at com.mongodb.internal.operation.FindOperation.lambda$execute$1(FindOperation.java:666) at com.mongodb.internal.operation.OperationHelper.lambda$withSourceAndConnection$2(OperationHelper.java:564) at com.mongodb.internal.operation.OperationHelper.withSuppliedResource(OperationHelper.java:589) at com.mongodb.internal.operation.OperationHelper.lambda$withSourceAndConnection$3(OperationHelper.java:563) at com.mongodb.internal.operation.OperationHelper.withSuppliedResource(OperationHelper.java:589) at com.mongodb.internal.operation.OperationHelper.withSourceAndConnection(OperationHelper.java:562) at com.mongodb.internal.operation.FindOperation.lambda$execute$2(FindOperation.java:661) at com.mongodb.internal.async.function.RetryingSyncSupplier.get(RetryingSyncSupplier.java:65) at com.mongodb.internal.operation.FindOperation.execute(FindOperation.java:692) at com.mongodb.internal.operation.FindOperation.execute(FindOperation.java:86) at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:191) at com.mongodb.client.internal.MongoIterableImpl.execute(MongoIterableImpl.java:135) at com.mongodb.client.internal.MongoIterableImpl.iterator(MongoIterableImpl.java:92) at dev.morphia.query.MorphiaQuery.prepareCursor(MorphiaQuery.java:321) at dev.morphia.query.MorphiaQuery.iterator(MorphiaQuery.java:200) at com.ghx.data.mongo.EmployeeDAO.findAll(QuickTourTest.java:397) at com.ghx.data.mongo.QuickTourTest.demo(QuickTourTest.java:149) Caused by: org.bson.codecs.configuration.CodecConfigurationException: Cannot find a public constructor for 'ZonedDateTime'. at org.bson.codecs.pojo.CreatorExecutable.checkHasAnExecutable(CreatorExecutable.java:140) at org.bson.codecs.pojo.CreatorExecutable.getInstance(CreatorExecutable.java:107) at org.bson.codecs.pojo.InstanceCreatorImpl.<init>(InstanceCreatorImpl.java:40) at org.bson.codecs.pojo.InstanceCreatorFactoryImpl.create(InstanceCreatorFactoryImpl.java:28) at org.bson.codecs.pojo.ClassModel.getInstanceCreator(ClassModel.java:75) at org.bson.codecs.pojo.PojoCodecImpl.decode(PojoCodecImpl.java:102) at org.bson.codecs.pojo.PojoCodecImpl.decode(PojoCodecImpl.java:107) at org.bson.codecs.pojo.AutomaticPojoCodec.decode(AutomaticPojoCodec.java:37) .
Additional Background
Please provide any additional background information that may be helpful in diagnosing the bug.