When i create a new spring boot project with admin and client & new Object mapper it fails.
Hi there, I face a issue here, "When i create a new spring boot project with admin and server & new Object mapper it fails.", I just tried to create object mapper to other rest client then i realised my spring boot admin doesn't work anymore!, please let me know how to fix this issue.
@EnableAdminServer
@SpringBootApplication
public class DemoApp {
public static void main(String[] args) {
SpringApplication.run(LogViewerApplication.class, args);
}
@Bean(name = "newObjectMapper")
public ObjectMapper newObjectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
return objectMapper;
}
}
LOG: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of de.codecentric.boot.admin.server.domain.values.Registration (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator) at [Source: REDACTED (StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION disabled); line: 1, column: 2]
Well after playing around, I see an issue there. I want to appologise for the previous comment.
- Are you using Spring Boot Admin and Spring Boot Admin Client in the same project?
- Which versions of Spring Boot Admin do you use?
- What kind of client registration do you rely on?
Yes, I am using both the Spring Boot Admin Server and Client within the same project, using the latest Spring Boot version (3.5.3) along with Spring Boot Admin and Admin Client version 3.5.0. Below is my current configuration:
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
spring.boot.admin.client.url=http://localhost:8080
Hi there, I face a issue here, "When i create a new spring boot project with admin and server & new Object mapper it fails.", I just tried to create object mapper to other rest client then i realised my spring boot admin doesn't work anymore!, please let me know how to fix this issue.
@EnableAdminServer @SpringBootApplication public class DemoApp { public static void main(String[] args) { SpringApplication.run(LogViewerApplication.class, args); } @Bean(name = "newObjectMapper") public ObjectMapper newObjectMapper() { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); return objectMapper; } }LOG:
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance ofde.codecentric.boot.admin.server.domain.values.Registration(no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator) at [Source: REDACTED (StreamReadFeature.INCLUDE_SOURCE_IN_LOCATIONdisabled); line: 1, column: 2]
@ganeshbabugb It seems like your object mapper is replacing the one used by SBA. If you want to keep your own, I would register the required modules in it with
mapper.registerModule(new AdminServerModule());
mapper.registerModule(new JavaTimeModule());
@SteKoe I think SBA should define it's own isolated ObjectMapper in the same way Spring Boot is now doing since version 3.x for the Actuator endpoints. :)