question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] ObjectMapperHolder destroys Spring autoconfiguration-pattern

See original GitHub issue

Describe the bug Using Spring-Boot you get some Utility-Beans configured automatically depending on the Libraries in your classpath. For Example the Jackson ObjecMapper class ist configured using properties and dependencies from the classpath and published in the Spring-ApplicationContext to be used by every component of the Spring Application.

Azure-messaging for Spring breaks this Pattern by using the com.azure.spring.messaging.implementation.converter.ObjectMapperHolder

Exception or Stack Trace This Antipattern leads to:

 com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type `java.time.LocalDateTime` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: de.bertelsmann.ols.old.model.partner.DmdParPartner["accedeDate"])

for Example

To Reproduce Steps to reproduce the behavior: Customize your Jackson-Framework like described in the Spring-Reference Documentation and you will see that this Customisations are noch used by the Azure-Messaging System.

Expected behavior A Library with the Name “spring-messaging-azure” should integrate with teh Spring-Framework and spacially use Spring Configuration-Options.

Setup (please complete the following information): Pom.xml with:

<parent>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-parent</artifactId>
	<version>2.7.1</version>
	<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
	<java.version>11</java.version>
	<spring-cloud.version>2021.0.3</spring-cloud.version>
        <jackson.datatype.jsr310.version>2.13.3</jackson.datatype.jsr310.version>
</properties>
<dependencyManagement>
	<dependencies>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-dependencies</artifactId>
			<version>${spring-cloud.version}</version>
			<type>pom</type>
			<scope>import</scope>
		</dependency>
		<dependency>
		      <groupId>com.azure.spring</groupId>
		      <artifactId>spring-cloud-azure-dependencies</artifactId>
		      <version>4.3.0</version>
		      <type>pom</type>
		      <scope>import</scope>
		</dependency>
		<dependency>
		      <groupId>com.fasterxml.jackson.datatype</groupId>
		      <artifactId>jackson-datatype-jsr310</artifactId>
		      <version>${jackson.datatype.jsr310.version}</version>
		</dependency>
	</dependencies>
</dependencyManagement>

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Klaus-BPG-ITcommented, Nov 8, 2022

When i use Spring-Boot i expect that librarys for Spring-Boot use the ObjectMapper from the ApplicationContext or they create a specific ObjectMapper-Bean in the ApplicationContext. I think the Design-Flaw and what Fix is expexted was described in my first Post.

0reactions
Netyyyycommented, Nov 14, 2022

Spring Boot uses the default ObjectMapper created by JacksonAutoConfiguration, which will be managed by IoC. So we can use the default ObjectMapper to replace the one created by ObjectMapperHolder. And I think AWS also uses this way to get an ObjectMapper in S3AutoConfiguration.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring Boot Reference Guide
Spring Boot Applications Deployment: Cloud Deployment | OS Service; Build tool plugins: Maven | Gradle; Appendix: Application Properties | Auto-configuration ...
Read more >
Chapter 184. JSon Jackson DataFormat Red Hat Fuse 7.8
184.2. Spring Boot Auto-Configuration ; camel.dataformat.json-jackson.unmarshal-type-name. Class name of the java type to use when unarmshalling. String ; camel.
Read more >
Spring-official-reference/guide.md at master · caojiele/Spring-official ...
SpringApplication will bootstrap our application, starting Spring which will in turn start the auto-configured Tomcat web server. We need to pass Example.class ...
Read more >
[PDF] Spring Boot - Tutorialspoint
This tutorial is designed for Java developers to understand and develop production-ready spring applications with minimum configurations. It explores major ...
Read more >
Spring Boot Reference Guide - developer - online - documents
Spring Boot makes it easy to create stand-alone, production-grade Spring based ... @JsonTest will auto-configure Jackson ObjectMapper , any @JsonComponent ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found