Skip to content

App fails to start when using Actuator with Jackson 2 and without spring-web #47788

@cachescrubber

Description

@cachescrubber

Spring Boot Starter Actuator and Jackson2 issue

When an application declares a dependency to spring-boot-starter-actuator (without webmvc) and jackson2 is on the class path, the application fails to start.

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</artifactId>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>

Demo Application

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.jackson.EndpointJackson2ObjectMapper]: Factory method 'jackson2EndpointJsonMapper' threw exception with message: org/springframework/http/converter/json/Jackson2ObjectMapperBuilder
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.lambda$instantiate$0(SimpleInstantiationStrategy.java:183)
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiateWithFactoryMethod(SimpleInstantiationStrategy.java:72)
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:152)
        at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
        ... 47 more
Caused by: java.lang.NoClassDefFoundError: org/springframework/http/converter/json/Jackson2ObjectMapperBuilder
        at org.springframework.boot.actuate.autoconfigure.endpoint.jackson.Jackson2EndpointAutoConfiguration.jackson2EndpointJsonMapper(Jackson2EndpointAutoConfiguration.java:47)
        at java.base/java.lang.reflect.Method.invoke(Method.java:565)
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.lambda$instantiate$0(SimpleInstantiationStrategy.java:155)
        ... 50 more
Caused by: java.lang.ClassNotFoundException: org.springframework.http.converter.json.Jackson2ObjectMapperBuilder
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:580)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:490)
        ... 53 more

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions