-
Bug
-
Resolution: Done
-
Major
-
7.1.0.DR7
-
None
Description of problem:
Jsr310 and jdk8 fasterxml modules are not available from deployment without specific jboss-deployment-structure.xml
How reproducible:
Always
Steps to Reproduce:
- This can be tested if "<module name="com.fasterxml.jackson.core.jackson-annotations"/>" is added to ./modules/system/layers/base/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/main/module.xml (see
JBEAP-6673)
- Create end-point with data types and special jdk8 types and allows
@GET @Path("entity/get/json") @Produces(MediaType.APPLICATION_JSON) public DatatypeObject getJson() { DatatypeObject per = new DatatypeObject(); per.setString("someString"); per.setDate(new Date()); per.setDuration(Duration.ofSeconds(5, 6)); per.setDayOfWeek(DayOfWeek.FRIDAY); per.setOptionalString1(Optional.of("info@example.com")); per.setOptionalString2(Optional.<String>empty()); return per; }
- Implement custom ContextResolver in deployment. This code enables jsr310 and jdk8 fasterxml functionality. Example:
@Provider @Produces( MediaType.APPLICATION_JSON ) public class JacksonProducer implements ContextResolver<ObjectMapper> { private final ObjectMapper json; public JacksonProducer() throws Exception { this.json = new ObjectMapper() .findAndRegisterModules() .configure( SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false ) .configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false ); } @Override public ObjectMapper getContext( Class<?> objectType ) { return json; } }
- Http request to REST end-point
Actual results:
{"string":"someString","optionalString1":{"present":true},"optionalString2":{"present":false},"duration":{"seconds":5,"zero":false,"negative":false,"units":["SECONDS","NANOS"],"nano":6},"date":"2016-10-27T13:02:11.991+0000"}
Expected results:
{"string":"someString","optionalString1":"info@example.com","optionalString2":null,"duration":"PT5.000000006S","date":"2016-10-27T13:01:03.923+0000"}
Workaround:
Expected results is returned if specific jboss-deployment-structure.xml file is used:
<?xml version="1.0" encoding="UTF-8"?> <jboss-deployment-structure> <deployment> <dependencies> <module name="com.fasterxml.jackson.datatype.jackson-datatype-jdk8" services="import"/> <module name="com.fasterxml.jackson.datatype.jackson-datatype-jsr310" services="import"/> </dependencies> </deployment> </jboss-deployment-structure>
- is cloned by
-
WFLY-7403 Jsr310 and jdk8 fasterxml modules are not available from deployment without specific jboss-deployment-structure.xml
- Closed
- relates to
-
JBEAP-6673 NoClassDefFoundError exception is thrown if jsr310 fasterxml module is used
- Closed