Closed tinolazreg closed 1 year ago
any update on this?
Should mapper.writeValueAsString(outOfStockProblem.toString());
be mapper.writeValueAsString(outOfStockProblem);
in initial code snippet?
Add this to you code and it should solve the problem. It solved for me.
@RequiredArgsConstructor
@Configuration
@EnableWebMvc
public class WebConfiguration implements WebMvcConfigurer {
@Autowired
private final ObjectMapper objectMapper;
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.add(new MappingJackson2HttpMessageConverter(objectMapper));
}
@Bean
public ObjectMapper objectMapper() {
return new ObjectMapper()
.registerModule(new Jdk8Module())
.registerModule(new JavaTimeModule())
.registerModule(new ProblemModule())
.registerModule(new ConstraintViolationProblemModule());
}
}
Description
We are using Java modules system, and our trying to use both problem and jackson-datatype-problem to be able to serialize and deserialize problems.
Example code:
mapper.readValue(serializedProblem, Problem.class);
throws an exception in this case with stack trace:Expected Behavior
Serialization and deserialization should work.
Actual Behavior
Exception is thrown.
Possible Fix
Seems like there are still more issues with how the Java modules are set-up.
Steps to Reproduce
See 'Description'
Context
Your Environment