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

BindingsLifecycleController isolated ObjectMapper caused jsr310 error at /actuator/bindings endpoint #2272

Closed
davidgjm opened this issue Jan 28, 2022 · 12 comments

Comments

@davidgjm
Copy link

Hi,

I got Java 8 date/time type java.time.Duration not supported by default error when trying to query the {baseUrl}/actuator/bindings endpoint. Based on current code, there is no way to add the JSR310 module either through dependency management or spring boot configuration. spring.jackson.* JacksonProperties won't work because the ObjectMapper instance being used is not managed by Spring. The error message I got is:

java.lang.IllegalArgumentException: Java 8 date/time type `java.time.Duration` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: org.springframework.cloud.stream.binder.ExtendedConsumerProperties["extension"]->com.azure.spring.eventhub.stream.binder.properties.EventHubConsumerProperties["checkpointInterval"]) (through reference chain: java.util.ArrayList[0]->org.springframework.cloud.stream.binder.AbstractMessageChannelBinder$2["extendedInfo"])

Version information

  • Spring Boot: 2.5.6
  • Spring Cloud: 2020.0.4
  • Jackson modules: 2.12.5 (bom version managed by Spring Boot)
  • Spring Cloud Stream: 3.1.4
  • Azure Spring Cloud Stream binder eventhubs: 2.10.0

Gradle configuration (part)

//    implementation 'org.springframework.boot:spring-boot-starter-json'
    implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
    implementation 'org.springframework.boot:spring-boot-starter-webflux'

    //actuator
    runtimeOnly 'org.springframework.boot:spring-boot-starter-actuator'

   //Spring Cloud Stream
    implementation 'org.springframework.cloud:spring-cloud-stream'

    //Azure SDK libraries
    implementation 'com.microsoft.azure:msal4j'
    implementation 'com.azure.spring:azure-spring-cloud-stream-binder-eventhubs'

Exception stacktrace

2022-01-28T02:33:48.037Z ERROR [,,] 53369 --- [boundedElastic-8] a.w.r.e.AbstractErrorWebExceptionHandler : [dd6155ee-1]  500 Server Error for HTTP GET "/actuator/bindings"

java.lang.IllegalArgumentException: Java 8 date/time type `java.time.Duration` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: org.springframework.cloud.stream.binder.ExtendedConsumerProperties["extension"]->com.azure.spring.eventhub.stream.binder.properties.EventHubConsumerProperties["checkpointInterval"]) (through reference chain: java.util.ArrayList[0]->org.springframework.cloud.stream.binder.AbstractMessageChannelBinder$2["extendedInfo"])
	at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:4314)
	Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Error has been observed at the following site(s):
	*__checkpointHandler org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping$ReadOperationHandler#handle(ServerWebExchange) [DispatcherHandler]
	*__checkpointorg.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]
	*__checkpointHTTP GET "/actuator/bindings" [ExceptionHandlingWebHandler]
Stack trace:
		at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:4314)
		at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:4245)
		at org.springframework.cloud.stream.binding.BindingsLifecycleController.queryStates(BindingsLifecycleController.java:124)
		at org.springframework.cloud.stream.endpoint.BindingsEndpoint.queryStates(BindingsEndpoint.java:52)
		at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
		at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
		at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
		at java.base/java.lang.reflect.Method.invoke(Method.java:566)
		at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:282)
		at org.springframework.boot.actuate.endpoint.invoke.reflect.ReflectiveOperationInvoker.invoke(ReflectiveOperationInvoker.java:74)
		at org.springframework.boot.actuate.endpoint.annotation.AbstractDiscoveredOperation.invoke(AbstractDiscoveredOperation.java:60)
		at org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping$ElasticSchedulerInvoker.lambda$invoke$0(AbstractWebFluxEndpointHandlerMapping.java:228)
		at reactor.core.publisher.MonoCallable.call(MonoCallable.java:92)
		at reactor.core.publisher.FluxSubscribeOnCallable$CallableSubscribeOnSubscription.run(FluxSubscribeOnCallable.java:227)
		at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68)
		at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28)
		at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
		at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
		at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
		at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
		at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Java 8 date/time type `java.time.Duration` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: org.springframework.cloud.stream.binder.ExtendedConsumerProperties["extension"]->com.azure.spring.eventhub.stream.binder.properties.EventHubConsumerProperties["checkpointInterval"]) (through reference chain: java.util.ArrayList[0]->org.springframework.cloud.stream.binder.AbstractMessageChannelBinder$2["extendedInfo"])
	at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:390)
	at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:349)
	at com.fasterxml.jackson.databind.ser.std.StdSerializer.wrapAndThrow(StdSerializer.java:316)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Java 8 date/time type `java.time.Duration` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: org.springframework.cloud.stream.binder.ExtendedConsumerProperties["extension"]->com.azure.spring.eventhub.stream.binder.properties.EventHubConsumerProperties["checkpointInterval"]) (through reference chain: java.util.ArrayList[0]->org.springframework.cloud.stream.binder.AbstractMessageChannelBinder$2["extendedInfo"])

	at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:778)
	at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:119)
	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:79)
	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:18)
	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319)
	at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:4292)
	at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:4245)
	at org.springframework.cloud.stream.binding.BindingsLifecycleController.queryStates(BindingsLifecycleController.java:124)
	at org.springframework.cloud.stream.endpoint.BindingsEndpoint.queryStates(BindingsEndpoint.java:52)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:282)
	at org.springframework.boot.actuate.endpoint.invoke.reflect.ReflectiveOperationInvoker.invoke(ReflectiveOperationInvoker.java:74)
	at org.springframework.boot.actuate.endpoint.annotation.AbstractDiscoveredOperation.invoke(AbstractDiscoveredOperation.java:60)
	at org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping$ElasticSchedulerInvoker.lambda$invoke$0(AbstractWebFluxEndpointHandlerMapping.java:228)
	at reactor.core.publisher.MonoCallable.call(MonoCallable.java:92)
	at reactor.core.publisher.FluxSubscribeOnCallable$CallableSubscribeOnSubscription.run(FluxSubscribeOnCallable.java:227)
	at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68)
	at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalArgumentException: Java 8 date/time type `java.time.Duration` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: org.springframework.cloud.stream.binder.ExtendedConsumerProperties["extension"]->com.azure.spring.eventhub.stream.binder.properties.EventHubConsumerProperties["checkpointInterval"])
	at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:4314)
	at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:4245)
	at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doGetExtendedInfo(AbstractMessageChannelBinder.java:921)
	at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.access$100(AbstractMessageChannelBinder.java:91)
	at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder$2.getExtendedInfo(AbstractMessageChannelBinder.java:424)
Caused by: java.lang.IllegalArgumentException: Java 8 date/time type `java.time.Duration` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: org.springframework.cloud.stream.binder.ExtendedConsumerProperties["extension"]->com.azure.spring.eventhub.stream.binder.properties.EventHubConsumerProperties["checkpointInterval"])

	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:689)
	at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770)
	... 27 common frames omitted
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type `java.time.Duration` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: org.springframework.cloud.stream.binder.ExtendedConsumerProperties["extension"]->com.azure.spring.eventhub.stream.binder.properties.EventHubConsumerProperties["checkpointInterval"])
	at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:77)
	at com.fasterxml.jackson.databind.SerializerProvider.reportBadDefinition(SerializerProvider.java:1276)
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type `java.time.Duration` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: org.springframework.cloud.stream.binder.ExtendedConsumerProperties["extension"]->com.azure.spring.eventhub.stream.binder.properties.EventHubConsumerProperties["checkpointInterval"])

	at com.fasterxml.jackson.databind.ser.impl.UnsupportedTypeSerializer.serialize(UnsupportedTypeSerializer.java:35)
	at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:728)
	at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770)
	at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
	at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:728)
	at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770)
	at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319)
	at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:4292)
	... 37 common frames omitted
@olegz
Copy link
Contributor

olegz commented Feb 1, 2022

I hear you. We tried to use "provided" ObjectMapper for this case but it was creating interference with other things when people were trying to configure it.
So I am thinking of making some kind of a way for configuring this specific ObjectMapper or provide user with ability to register their own ObjectMapper.

@olegz
Copy link
Contributor

olegz commented Feb 1, 2022

In fact there is a comment which points to #2253

this.objectMapper = new ObjectMapper(); //see https://github.com/spring-cloud/spring-cloud-stream/issues/2253
// we need to use ObjectMapper that could not be modified by the user.

@olegz
Copy link
Contributor

olegz commented Feb 1, 2022

Given that this is the first time someone ever reported issue with BindingsLifecycleController i am inclined to treat it as an edge case, so for now I am going to simply add JavaModule and keep this ObjectMapper isolated. If we start having similar issues then we would come up with a more extendable strategy

olegz added a commit that referenced this issue Feb 1, 2022
olegz added a commit that referenced this issue Feb 1, 2022
@olegz olegz closed this as completed in c5fd0be Feb 1, 2022
@azizabah
Copy link

azizabah commented Feb 4, 2022

@olegz - Is there a workaround for this or will we have to wait for next release?

@olegz
Copy link
Contributor

olegz commented Feb 7, 2022

@azizabah
You can implement BeanPostProcessor and use java reflection to set your ObjectMapper and register it as a bean
Here is how you would do it

@Bean
public BeanPostProcessor mapperReplacer() {
	return new BeanPostProcessor() {
		public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
			if (bean instanceof BindingsLifecycleController) {
				Field field = ReflectionUtils.findField(bean.getClass(), "objectMapper");
				field.setAccessible(true);
				ObjectMapper mapper = new ObjectMapper();
				// do your configuration
				try {
					field.set(bean, mapper);
				} catch (Exception e) {
					throw new IllegalStateException(e);
				} 
			}
			return bean;
		}
	};
}

@azizabah
Copy link

@bean
public BeanPostProcessor mapperReplacer() {
return new BeanPostProcessor() {
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof BindingsLifecycleController) {
Field field = ReflectionUtils.findField(bean.getClass(), "objectMapper");
field.setAccessible(true);
ObjectMapper mapper = new ObjectMapper();
// do your configuration
try {
field.set(bean, mapper);
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
return bean;
}
};
}

Appreciate the example but it still blows up with the same error. Instead of configuring a new ObjectMapper, I just grabbed the one from the ApplicationContext. I also tried creating a new one and registering the JavaTimeModule. Same results.

Can we add a test here: https://github.com/spring-cloud/spring-cloud-stream/blob/main/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/endpoint/ActuatorBindingsTest.java to prevent regression bugs in the future?

@kxying-kk
Copy link

Hi,

I got Java 8 date/time type java.time.Duration not supported by default error when trying to query the {baseUrl}/actuator/bindings endpoint. Based on current code, there is no way to add the JSR310 module either through dependency management or spring boot configuration. spring.jackson.* JacksonProperties won't work because the ObjectMapper instance being used is not managed by Spring. The error message I got is:

java.lang.IllegalArgumentException: Java 8 date/time type `java.time.Duration` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: org.springframework.cloud.stream.binder.ExtendedConsumerProperties["extension"]->com.azure.spring.eventhub.stream.binder.properties.EventHubConsumerProperties["checkpointInterval"]) (through reference chain: java.util.ArrayList[0]->org.springframework.cloud.stream.binder.AbstractMessageChannelBinder$2["extendedInfo"])

Version information

  • Spring Boot: 2.5.6
  • Spring Cloud: 2020.0.4
  • Jackson modules: 2.12.5 (bom version managed by Spring Boot)
  • Spring Cloud Stream: 3.1.4
  • Azure Spring Cloud Stream binder eventhubs: 2.10.0

Gradle configuration (part)

//    implementation 'org.springframework.boot:spring-boot-starter-json'
    implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
    implementation 'org.springframework.boot:spring-boot-starter-webflux'

    //actuator
    runtimeOnly 'org.springframework.boot:spring-boot-starter-actuator'

   //Spring Cloud Stream
    implementation 'org.springframework.cloud:spring-cloud-stream'

    //Azure SDK libraries
    implementation 'com.microsoft.azure:msal4j'
    implementation 'com.azure.spring:azure-spring-cloud-stream-binder-eventhubs'

Exception stacktrace

2022-01-28T02:33:48.037Z ERROR [,,] 53369 --- [boundedElastic-8] a.w.r.e.AbstractErrorWebExceptionHandler : [dd6155ee-1]  500 Server Error for HTTP GET "/actuator/bindings"

java.lang.IllegalArgumentException: Java 8 date/time type `java.time.Duration` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: org.springframework.cloud.stream.binder.ExtendedConsumerProperties["extension"]->com.azure.spring.eventhub.stream.binder.properties.EventHubConsumerProperties["checkpointInterval"]) (through reference chain: java.util.ArrayList[0]->org.springframework.cloud.stream.binder.AbstractMessageChannelBinder$2["extendedInfo"])
	at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:4314)
	Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Error has been observed at the following site(s):
	*__checkpointHandler org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping$ReadOperationHandler#handle(ServerWebExchange) [DispatcherHandler]
	*__checkpointorg.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]
	*__checkpointHTTP GET "/actuator/bindings" [ExceptionHandlingWebHandler]
Stack trace:
		at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:4314)
		at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:4245)
		at org.springframework.cloud.stream.binding.BindingsLifecycleController.queryStates(BindingsLifecycleController.java:124)
		at org.springframework.cloud.stream.endpoint.BindingsEndpoint.queryStates(BindingsEndpoint.java:52)
		at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
		at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
		at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
		at java.base/java.lang.reflect.Method.invoke(Method.java:566)
		at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:282)
		at org.springframework.boot.actuate.endpoint.invoke.reflect.ReflectiveOperationInvoker.invoke(ReflectiveOperationInvoker.java:74)
		at org.springframework.boot.actuate.endpoint.annotation.AbstractDiscoveredOperation.invoke(AbstractDiscoveredOperation.java:60)
		at org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping$ElasticSchedulerInvoker.lambda$invoke$0(AbstractWebFluxEndpointHandlerMapping.java:228)
		at reactor.core.publisher.MonoCallable.call(MonoCallable.java:92)
		at reactor.core.publisher.FluxSubscribeOnCallable$CallableSubscribeOnSubscription.run(FluxSubscribeOnCallable.java:227)
		at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68)
		at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28)
		at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
		at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
		at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
		at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
		at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Java 8 date/time type `java.time.Duration` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: org.springframework.cloud.stream.binder.ExtendedConsumerProperties["extension"]->com.azure.spring.eventhub.stream.binder.properties.EventHubConsumerProperties["checkpointInterval"]) (through reference chain: java.util.ArrayList[0]->org.springframework.cloud.stream.binder.AbstractMessageChannelBinder$2["extendedInfo"])
	at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:390)
	at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:349)
	at com.fasterxml.jackson.databind.ser.std.StdSerializer.wrapAndThrow(StdSerializer.java:316)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Java 8 date/time type `java.time.Duration` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: org.springframework.cloud.stream.binder.ExtendedConsumerProperties["extension"]->com.azure.spring.eventhub.stream.binder.properties.EventHubConsumerProperties["checkpointInterval"]) (through reference chain: java.util.ArrayList[0]->org.springframework.cloud.stream.binder.AbstractMessageChannelBinder$2["extendedInfo"])

	at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:778)
	at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:119)
	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:79)
	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:18)
	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319)
	at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:4292)
	at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:4245)
	at org.springframework.cloud.stream.binding.BindingsLifecycleController.queryStates(BindingsLifecycleController.java:124)
	at org.springframework.cloud.stream.endpoint.BindingsEndpoint.queryStates(BindingsEndpoint.java:52)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:282)
	at org.springframework.boot.actuate.endpoint.invoke.reflect.ReflectiveOperationInvoker.invoke(ReflectiveOperationInvoker.java:74)
	at org.springframework.boot.actuate.endpoint.annotation.AbstractDiscoveredOperation.invoke(AbstractDiscoveredOperation.java:60)
	at org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping$ElasticSchedulerInvoker.lambda$invoke$0(AbstractWebFluxEndpointHandlerMapping.java:228)
	at reactor.core.publisher.MonoCallable.call(MonoCallable.java:92)
	at reactor.core.publisher.FluxSubscribeOnCallable$CallableSubscribeOnSubscription.run(FluxSubscribeOnCallable.java:227)
	at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68)
	at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalArgumentException: Java 8 date/time type `java.time.Duration` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: org.springframework.cloud.stream.binder.ExtendedConsumerProperties["extension"]->com.azure.spring.eventhub.stream.binder.properties.EventHubConsumerProperties["checkpointInterval"])
	at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:4314)
	at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:4245)
	at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doGetExtendedInfo(AbstractMessageChannelBinder.java:921)
	at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.access$100(AbstractMessageChannelBinder.java:91)
	at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder$2.getExtendedInfo(AbstractMessageChannelBinder.java:424)
Caused by: java.lang.IllegalArgumentException: Java 8 date/time type `java.time.Duration` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: org.springframework.cloud.stream.binder.ExtendedConsumerProperties["extension"]->com.azure.spring.eventhub.stream.binder.properties.EventHubConsumerProperties["checkpointInterval"])

	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:689)
	at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770)
	... 27 common frames omitted
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type `java.time.Duration` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: org.springframework.cloud.stream.binder.ExtendedConsumerProperties["extension"]->com.azure.spring.eventhub.stream.binder.properties.EventHubConsumerProperties["checkpointInterval"])
	at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:77)
	at com.fasterxml.jackson.databind.SerializerProvider.reportBadDefinition(SerializerProvider.java:1276)
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type `java.time.Duration` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: org.springframework.cloud.stream.binder.ExtendedConsumerProperties["extension"]->com.azure.spring.eventhub.stream.binder.properties.EventHubConsumerProperties["checkpointInterval"])

	at com.fasterxml.jackson.databind.ser.impl.UnsupportedTypeSerializer.serialize(UnsupportedTypeSerializer.java:35)
	at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:728)
	at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770)
	at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
	at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:728)
	at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770)
	at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319)
	at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:4292)
	... 37 common frames omitted

Hi. @davidgjm did you get his issue solved at the end? thanks

@kxying-kk
Copy link

@olegz

I am having the same issue today after I migrate the springboot/azure servicebus version.

spring boot : 2.7.0
spring cloud: 2021.03
com.azure.spring(spring-cloud-azure-stream-binder-servicebus): 4.2.0

@olegz
Copy link
Contributor

olegz commented Sep 21, 2023

Do you have the following on classpath?

<dependency>
    <groupId>com.fasterxml.jackson.datatype</groupId>
    <artifactId>jackson-datatype-jsr310</artifactId>
</dependency>

@saragluna
Copy link

@olegz seems like the error comes from the

Map<String, Object> extendedInfo = new LinkedHashMap<>();
extendedInfo.put("bindingDestination", destination.toString());
extendedInfo.put(properties.getClass().getSimpleName(),
this.objectMapper.convertValue(properties, Map.class));
return extendedInfo;
, which doesn't register the JavaTimeModule,
if (!CollectionUtils.isEmpty(this.getApplicationContext().getBeansOfType(ObjectMapper.class))) {
this.objectMapper = this.getApplicationContext().getBean(ObjectMapper.class);
}
else {
this.objectMapper = new ObjectMapper();
}
SimpleModule module = new SimpleModule();
module.addSerializer(Expression.class, new ExpressionSerializer(Expression.class));
this.objectMapper.registerModule(module);
.

Is there a workaround for this?

@juliojgd
Copy link

@olegz Should this issue be reopened? You commented you were closing it as there were no reports related with this, but it seems several reports right now, so it does not seem as a "edge case".

I will appreciate if this is reopened.

@sobychacko
Copy link
Contributor

Let's continue the discussion on the issue #2794? This seems to be a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants