org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class java.time.ZonedDateTime.

Spring JIRA | Mark Paluch | 7 months ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    MongoRepository findAll with ZonedDateTime predicate runs into CodecConfigurationException

    Stack Overflow | 7 months ago | pDer666
    org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class java.time.ZonedDateTime.
  2. 0

    Suppose we have a class and a repository declaration using QueryDsl {code} public class MyDocument { … ZonedDateTime remoteTime; … } public interface MyRepository extends MongoRepository<MyDocument, String>, QueryDslPredicateExecutor<MyDocument>{} {code} if the document is queried with {code} ZonedDateTime now = ZonedDateTime.now(); repository.findAll(QMyDocument.myDocument.remoteTime.between(now.minusDays(1), now.plusDays(1))); {code} then following exception is thrown: {code} org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class java.time.ZonedDateTime. 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 com.mongodb.DBObjectCodec.writeValue(DBObjectCodec.java:210) at com.mongodb.DBObjectCodec.encodeMap(DBObjectCodec.java:220) at com.mongodb.DBObjectCodec.writeValue(DBObjectCodec.java:196) at com.mongodb.DBObjectCodec.encode(DBObjectCodec.java:128) at com.mongodb.DBObjectCodec.encode(DBObjectCodec.java:61) 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:133) at org.bson.codecs.BsonDocumentCodec.encode(BsonDocumentCodec.java:112) at org.bson.codecs.BsonDocumentCodec.encode(BsonDocumentCodec.java:40) 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.CommandProtocol.sendMessage(CommandProtocol.java:192) at com.mongodb.connection.CommandProtocol.execute(CommandProtocol.java:111) at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:159) at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:286) at com.mongodb.connection.DefaultServerConnection.command(DefaultServerConnection.java:173) at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:215) at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:206) at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:112) at com.mongodb.operation.CountOperation$1.call(CountOperation.java:210) at com.mongodb.operation.CountOperation$1.call(CountOperation.java:206) at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:230) at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:203) at com.mongodb.operation.CountOperation.execute(CountOperation.java:206) at com.mongodb.operation.CountOperation.execute(CountOperation.java:53) at com.mongodb.Mongo.execute(Mongo.java:772) at com.mongodb.Mongo$2.execute(Mongo.java:759) at com.mongodb.DBCollection.getCount(DBCollection.java:962) at com.mongodb.DBCollection.getCount(DBCollection.java:937) at com.mongodb.DBCollection.getCount(DBCollection.java:931) at com.mongodb.DBCollection.getCount(DBCollection.java:914) at com.mongodb.DBCollection.getCount(DBCollection.java:885) at com.mongodb.DBCollection.count(DBCollection.java:824) at com.querydsl.mongodb.AbstractMongodbQuery.fetchCount(AbstractMongodbQuery.java:391) at com.querydsl.mongodb.AbstractMongodbQuery.fetchResults(AbstractMongodbQuery.java:376) at org.springframework.data.mongodb.repository.support.QueryDslMongoRepository.findAll(QueryDslMongoRepository.java:104) at org.springframework.data.mongodb.repository.support.QueryDslMongoRepository.findAll(QueryDslMongoRepository.java:50) 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.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:503) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:488) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) at com.sun.proxy.$Proxy69.findAll(Unknown Source) at com.favendo.squirrel.persistence.CrudNutRepositoryTests.readTimeFrame(CrudNutRepositoryTests.java:83) {code}

    Spring JIRA | 7 months ago | Mark Paluch
    org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class java.time.ZonedDateTime.
  3. 0

    spring mongo querydsl Can't find a codec for class java.time.LocalDateTime

    Stack Overflow | 4 months ago | Kery Hu
    org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class java.time.LocalDateTime.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.bson.codecs.configuration.CodecConfigurationException

      Can't find a codec for class java.time.ZonedDateTime.

      at org.bson.codecs.configuration.CodecCache.getOrThrow()
    2. MongoDB Java Driver
      DBCollection.count
      1. org.bson.codecs.configuration.CodecCache.getOrThrow(CodecCache.java:46)
      2. org.bson.codecs.configuration.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:63)
      3. org.bson.codecs.configuration.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:37)
      4. com.mongodb.DBObjectCodec.writeValue(DBObjectCodec.java:210)
      5. com.mongodb.DBObjectCodec.encodeMap(DBObjectCodec.java:220)
      6. com.mongodb.DBObjectCodec.writeValue(DBObjectCodec.java:196)
      7. com.mongodb.DBObjectCodec.encode(DBObjectCodec.java:128)
      8. com.mongodb.DBObjectCodec.encode(DBObjectCodec.java:61)
      9. org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63)
      10. org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29)
      11. org.bson.codecs.EncoderContext.encodeWithChildContext(EncoderContext.java:91)
      12. org.bson.codecs.BsonDocumentCodec.writeValue(BsonDocumentCodec.java:133)
      13. org.bson.codecs.BsonDocumentCodec.encode(BsonDocumentCodec.java:112)
      14. org.bson.codecs.BsonDocumentCodec.encode(BsonDocumentCodec.java:40)
      15. com.mongodb.connection.RequestMessage.addDocument(RequestMessage.java:253)
      16. com.mongodb.connection.RequestMessage.addDocument(RequestMessage.java:205)
      17. com.mongodb.connection.CommandMessage.encodeMessageBodyWithMetadata(CommandMessage.java:75)
      18. com.mongodb.connection.RequestMessage.encodeWithMetadata(RequestMessage.java:160)
      19. com.mongodb.connection.CommandProtocol.sendMessage(CommandProtocol.java:192)
      20. com.mongodb.connection.CommandProtocol.execute(CommandProtocol.java:111)
      21. com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:159)
      22. com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:286)
      23. com.mongodb.connection.DefaultServerConnection.command(DefaultServerConnection.java:173)
      24. com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:215)
      25. com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:206)
      26. com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:112)
      27. com.mongodb.operation.CountOperation$1.call(CountOperation.java:210)
      28. com.mongodb.operation.CountOperation$1.call(CountOperation.java:206)
      29. com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:230)
      30. com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:203)
      31. com.mongodb.operation.CountOperation.execute(CountOperation.java:206)
      32. com.mongodb.operation.CountOperation.execute(CountOperation.java:53)
      33. com.mongodb.Mongo.execute(Mongo.java:772)
      34. com.mongodb.Mongo$2.execute(Mongo.java:759)
      35. com.mongodb.DBCollection.getCount(DBCollection.java:962)
      36. com.mongodb.DBCollection.getCount(DBCollection.java:937)
      37. com.mongodb.DBCollection.getCount(DBCollection.java:931)
      38. com.mongodb.DBCollection.getCount(DBCollection.java:914)
      39. com.mongodb.DBCollection.getCount(DBCollection.java:885)
      40. com.mongodb.DBCollection.count(DBCollection.java:824)
      40 frames
    3. com.querydsl.mongodb
      AbstractMongodbQuery.fetchResults
      1. com.querydsl.mongodb.AbstractMongodbQuery.fetchCount(AbstractMongodbQuery.java:391)
      2. com.querydsl.mongodb.AbstractMongodbQuery.fetchResults(AbstractMongodbQuery.java:376)
      2 frames
    4. Spring Data MongoDB - Core
      QueryDslMongoRepository.findAll
      1. org.springframework.data.mongodb.repository.support.QueryDslMongoRepository.findAll(QueryDslMongoRepository.java:104)
      2. org.springframework.data.mongodb.repository.support.QueryDslMongoRepository.findAll(QueryDslMongoRepository.java:50)
      2 frames
    5. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      4. java.lang.reflect.Method.invoke(Method.java:498)
      4 frames
    6. Spring Data Core
      RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke
      1. org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:503)
      2. org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:488)
      3. org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460)
      3 frames
    7. Spring AOP
      ReflectiveMethodInvocation.proceed
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      1 frame
    8. org.springframework.data
      DefaultMethodInvokingMethodInterceptor.invoke
      1. org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
      1 frame
    9. Spring AOP
      JdkDynamicAopProxy.invoke
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      2. org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
      3. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      4. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
      4 frames
    10. com.sun.proxy
      $Proxy69.findAll
      1. com.sun.proxy.$Proxy69.findAll(Unknown Source)
      1 frame
    11. com.favendo.squirrel
      CrudNutRepositoryTests.readTimeFrame
      1. com.favendo.squirrel.persistence.CrudNutRepositoryTests.readTimeFrame(CrudNutRepositoryTests.java:83)
      1 frame