Uploaded image for project: 'JBoss BPMS Platform'
  1. JBoss BPMS Platform
  2. RHBPMS-4510

[GSS][6.4.z]REST API different output when using JDK 1.8

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 6.4.1
    • 6.3.3.GA
    • Business Central
      • JDK 1.8
    • CR1
    • Workaround Exists
    • Hide

      My research so far on this issue makes me think that this is related to the Jackson JAXB support. For some reason the JAXB annotations works for JDK 1.8 and they are recognized. Jackson has this JAXB annotation introspector that due this change makes it work on JDK 1.8. Hence prevent this "annotation introspector" registration would solve this:

      • One way to prevent it from being registered is create a custom ObjectMapper (entry point to configure Jackson/JSON resteasy output) in RESTeasy. To do this we create a JAR with a simply ObjectMapper:
        import javax.ws.rs.Consumes;
        import javax.ws.rs.Produces;
        import javax.ws.rs.core.MediaType;
        import javax.ws.rs.ext.ContextResolver;
        import javax.ws.rs.ext.Provider;
        import org.codehaus.jackson.map.ObjectMapper;
        
        @Provider
        @Produces(MediaType.APPLICATION_JSON)
        @Consumes(MediaType.APPLICATION_JSON)
        public class CustomObjectMapper implements ContextResolver<ObjectMapper> {
        
                private final ObjectMapper objectMapper;
        
                public CustomObjectMapper() {
                        System.out.println("== Creating Custom Object Mapper ==");
                        objectMapper = new ObjectMapper();
                }
        
                public ObjectMapper getContext(Class<?> type) {
                        return objectMapper;
                }
        }
        
      • Another solution is simply remove the `jackson-jaxrs- {version}

        .jar` from `business-central.war/WEB-INF/lib` because in this jackson jaxrs is the JAXB annotation introspector registration.

      Show
      My research so far on this issue makes me think that this is related to the Jackson JAXB support. For some reason the JAXB annotations works for JDK 1.8 and they are recognized. Jackson has this JAXB annotation introspector that due this change makes it work on JDK 1.8. Hence prevent this "annotation introspector" registration would solve this: One way to prevent it from being registered is create a custom ObjectMapper (entry point to configure Jackson/JSON resteasy output) in RESTeasy. To do this we create a JAR with a simply ObjectMapper: import javax.ws.rs.Consumes; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.ext.ContextResolver; import javax.ws.rs.ext.Provider; import org.codehaus.jackson.map.ObjectMapper; @Provider @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public class CustomObjectMapper implements ContextResolver<ObjectMapper> { private final ObjectMapper objectMapper; public CustomObjectMapper() { System .out.println( "== Creating Custom Object Mapper ==" ); objectMapper = new ObjectMapper(); } public ObjectMapper getContext( Class <?> type) { return objectMapper; } } Another solution is simply remove the `jackson-jaxrs- {version} .jar` from `business-central.war/WEB-INF/lib` because in this jackson jaxrs is the JAXB annotation introspector registration.
    • Hide
      • Start BPM Suite using JDK 1.7;
      • Create instances of a process that has human tasks;
      • Use the `task/query` to query the tasks for a given process instance, see:
        ***$ curl -X GET -u 'bpmsAdmin:redhat2014!' -H 'Accept: application/json' http://localhost:8080/business-central/rest/task/query?processInstanceId=1***
        {"status":null,"url":null,"index":null,"commandName":null,"taskSummaryList":[{"@class":"org.kie.services.client.serialization.jaxb.impl.task.JaxbTaskSummary","id":1,"name":"Task_1","subject":"","description":"","status":"Reserved","priority":0,"skipable":true,"actualOwnerId":"bpmsAdmin","createdById":"bpmsAdmin","createdOn":1478042168434,"activationTime":1478042168434,"expirationTime":null,"processInstanceId":1,"processId":"test.test","processSessionId":2,"deploymentId":"example:test:1.0","quickTaskSummary":false,"parentId":-1,"potentialOwners":null}],"pageNumber":null,"pageSize":null}
        

      Notice the fields has no hyphen

      • Start BPM Suite using JDK 1.8
      • Check the same endpoint output. Check the hyphens on this version, for example:
        {
            "index": null,
            "taskSummaryList": [
                {
                    "@class": "org.kie.services.client.serialization.jaxb.impl.task.JaxbTaskSummary",
                    "id": 135,
                    "status": "Created",
                    "priority": 0,
                    "skipable": true,
                    "created-on": 1477603386560,
                    "activation-time": 1477603386560,
                    "process-instance-id": 390,
                    "process-id": "my-process",
                    "process-session-id": 311,
                    "deployment-id": "com.mycompany:my_proj:1.0",
                    "quick-task-summary": false,
                    "parent-id": -1
                }
            ]
        }
        
      Show
      Start BPM Suite using JDK 1.7; Create instances of a process that has human tasks; Use the `task/query` to query the tasks for a given process instance, see: ***$ curl -X GET -u 'bpmsAdmin:redhat2014!' -H 'Accept: application/json' http://localhost:8080/business-central/rest/task/query?processInstanceId=1*** { "status" : null , "url" : null , "index" : null , "commandName" : null , "taskSummaryList" :[{ "@class" : "org.kie.services.client.serialization.jaxb.impl.task.JaxbTaskSummary" , "id" :1, "name" : "Task_1" , "subject" : ""," description ":" "," status ":" Reserved "," priority ":0," skipable ": true ," actualOwnerId ":" bpmsAdmin "," createdById ":" bpmsAdmin "," createdOn ":1478042168434," activationTime ":1478042168434," expirationTime ": null ," processInstanceId ":1," processId ":" test.test "," processSessionId ":2," deploymentId ":" example:test:1.0 "," quickTaskSummary ": false ," parentId ":-1," potentialOwners ": null }]," pageNumber ": null ," pageSize": null } Notice the fields has no hyphen Start BPM Suite using JDK 1.8 Check the same endpoint output. Check the hyphens on this version, for example: { "index" : null , "taskSummaryList" : [ { "@class" : "org.kie.services.client.serialization.jaxb.impl.task.JaxbTaskSummary" , "id" : 135, "status" : "Created" , "priority" : 0, "skipable" : true , "created-on" : 1477603386560, "activation-time" : 1477603386560, "process-instance-id" : 390, "process-id" : "my-process" , "process-session-id" : 311, "deployment-id" : "com.mycompany:my_proj:1.0" , "quick-task-summary" : false , "parent-id" : -1 } ] }

      Some REST API JSON outputs in BPM Suite 6.3.3 contains hyphens in the attribute name. This only happen when we use the JDK 1.8.

      For example, the field `activationTime` in JDK 1.7 becomes `activation-time` with JDK 1.8.

      The problem is that it breaks the REST clients that were supposed to work.

              swiderski.maciej Maciej Swiderski (Inactive)
              rhn-support-wsiqueir William Siqueira
              Jiri Petrlik Jiri Petrlik
              Jiri Petrlik Jiri Petrlik
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: