Reputation: 1
I have a very simple REST app using JAX-RS, Tomcat 11, and Weld for CDI. It is pretty straightforward with only the following (ie no web.xml
or context.xml
):
jakarta.ws.rs.core.Application
@Path
and other associated annotations for the endpointsbeans.xml
and persistence.xml
(though not using JPA yet)org.jboss.weld.se:weld-se-core
v6.0.0.Beta4 for CDI.In the class that defines the endpoints, I want to return an object that has a ZonedDateTime
field. I followed the directions to findAndAddModules()
in a @Produces
class:
@ApplicationScoped
public class SerializerConfig {
private static final Logger logger = Logger.getLogger(SerializerConfig.class.getName());
@Produces
public JsonMapper objectMapper() {
logger.info("PROVIDING!!!");
return JsonMapper.builder()
.findAndAddModules()
.build();
}
}
This class is never called (don't see "PROVIDING!!!" in my logs) when I simply return Response.ok(obj_with_date_time).build();
.
How can I get Weld to provider my instance of JsonMapper
to whatever Jersey code is called when returning Response.ok(obj_with_date_time).build();
?
My provider is called if I specifically @Inject
JsonMapper
as a field in my class, and manually perform the serialization: jsonMapper.writeValueAsString(obj_with_date_time);
Upvotes: 0
Views: 18