[jboss-jira] [JBoss JIRA] (WFLY-7403) Jsr310 and jdk8 fasterxml modules are not available from deployment without specific jboss-deployment-structure.xml
Stuart Douglas (JIRA)
issues at jboss.org
Thu Oct 27 19:44:00 EDT 2016
[ https://issues.jboss.org/browse/WFLY-7403?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Stuart Douglas moved JBEAP-6691 to WFLY-7403:
---------------------------------------------
Project: WildFly (was: JBoss Enterprise Application Platform)
Key: WFLY-7403 (was: JBEAP-6691)
Workflow: GIT Pull Request workflow (was: CDW with loose statuses v1)
Component/s: REST
(was: REST)
Affects Version/s: (was: 7.1.0.DR7)
> Jsr310 and jdk8 fasterxml modules are not available from deployment without specific jboss-deployment-structure.xml
> -------------------------------------------------------------------------------------------------------------------
>
> Key: WFLY-7403
> URL: https://issues.jboss.org/browse/WFLY-7403
> Project: WildFly
> Issue Type: Bug
> Components: REST
> Reporter: Stuart Douglas
> Assignee: Stuart Douglas
>
> *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
> {code:java}
> @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 at example.com"));
> per.setOptionalString2(Optional.<String>empty());
> return per;
> }
> {code}
> # Implement custom ContextResolver in deployment. This code enables jsr310 and jdk8 fasterxml functionality. Example:
> {code:java}
> @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;
> }
> }
> {code}
> # Http request to REST end-point
> *Actual results:*
> {noformat}
> {"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"}
> {noformat}
> *Expected results:*
> {noformat}{"string":"someString","optionalString1":"info at example.com","optionalString2":null,"duration":"PT5.000000006S","date":"2016-10-27T13:01:03.923+0000"}
> {noformat}
> *Workaround:*
> Expected results is returned if specific jboss-deployment-structure.xml file is used:
> {code:xml}
> <?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>
> {code}
--
This message was sent by Atlassian JIRA
(v7.2.2#72004)
More information about the jboss-jira
mailing list