Uploaded image for project: 'jBPM'
  1. jBPM
  2. JBPM-4537

Error when getting a primitive type process instance variable when using the REST API

    XMLWordPrintable

Details

    • Hide

      Steps to Reproduce:
      1. Create a process with variables of type String, integer, float or boolean and a human task
      2. Deploy the project with the process
      3. When the process is waiting for the human task, try to retrieve the variable value using REST, for example:

      curl -u 'jesuino:redhat2014!' -H 'Accept: application/json' localhost:8080/business-central/rest/runtime/test:test:1.0/process/instance/2/variable/myVar
      
      Show
      Steps to Reproduce: 1. Create a process with variables of type String, integer, float or boolean and a human task 2. Deploy the project with the process 3. When the process is waiting for the human task, try to retrieve the variable value using REST, for example: curl -u 'jesuino:redhat2014!' -H 'Accept: application/json' localhost:8080/business-central/ rest /runtime/test:test:1.0/process/instance/2/variable/myVar

    Description

      process with variables of primitive types is started and when we try to retrieve this processes variables using the REST API, we have marshalling errors, such as:

      16:14:38,054 WARN [org.kie.remote.services.rest.exception.DescriptiveExceptionHandler] (http-localhost.localdomain/127.0.0.1:8080-5) Exception thrown when processing request [/runtime/com.redhat.consulting:TestProj:1.0/process/instance/4/variable/myVar]; responding with status 500: org.kie.remote.services.rest.exception.RestOperationException: Unable to serialize java.lang.String instance because it is missing a javax.xml.bind.annotation.XmlRootElement annotation with a name value.

      Endpoint: rest/runtime/PROCESS/process/instance/INSTANCE ID/variable/VAR_NAME
      It is not happening with complex types, only with primitive types: boolean, float, integer and String.

      Found that the Java implementation of this REST resource always treat the variable as a complex object and try to marshal it:

      RuntimeResource.java
          @GET
          @Path("/process/instance/{procInstId: [0-9]+}/variable/{varName: [\\w\\.-]+}")
          public Response process_instance_procInstId_variable_varName(@PathParam("procInstId") Long procInstId,
                  @PathParam("varName") String varName) {
              Object procVar =  processRequestBean.getVariableObjectInstanceFromRuntime(deploymentId, procInstId, varName);
          
              // serialize
              QName rootElementName = getRootElementName(procVar); 
              @SuppressWarnings("rawtypes") // unknown at compile time, dynamic from deployment
              JAXBElement<?> jaxbElem = new JAXBElement(rootElementName, procVar.getClass(), procVar) ;
          
              // return
              return createCorrectVariant(jaxbElem, headers);
          }
      

      Attachments

        Activity

          People

            rhn-support-wsiqueir William Siqueira
            rhn-support-wsiqueir William Siqueira
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: