cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with retrieving properties of task form via REST API

mprzycho
Champ in-the-making
Champ in-the-making
I tried to get properties of task from via:
http://localhost:8080/activiti-rest/service/form/{taskId}/properties

I got following exception:

WARNING: Exception or error caught in resource
java.lang.NullPointerException
        at org.codehaus.jackson.node.ObjectNode.toString(ObjectNode.java:344)
        at org.codehaus.jackson.node.ArrayNode.toString(ArrayNode.java:403)
        at org.codehaus.jackson.node.ObjectNode.toString(ObjectNode.java:344)
        at java.lang.String.valueOf(String.java:2826)
        at java.lang.StringBuilder.append(StringBuilder.java:115)
        at org.restlet.service.ConverterService.toRepresentation(ConverterService.java:213)
        at org.restlet.resource.UniformResource.toRepresentation(UniformResource.java:667)
        at org.restlet.resource.ServerResource.doHandle(ServerResource.java:464)
        at org.restlet.resource.ServerResource.get(ServerResource.java:645)
        at org.restlet.resource.ServerResource.doHandle(ServerResource.java:527)
        at org.restlet.resource.ServerResource.doNegotiatedHandle(ServerResource.java:587)
        at org.restlet.resource.ServerResource.doConditionalHandle(ServerResource.java:299)
        at org.restlet.resource.ServerResource.handle(ServerResource.java:846)
        at org.restlet.resource.Finder.handle(Finder.java:510)
        at org.restlet.routing.Filter.doHandle(Filter.java:156)
        at org.restlet.routing.Filter.handle(Filter.java:203)
        at org.restlet.routing.Router.doHandle(Router.java:497)
        at org.restlet.routing.Router.handle(Router.java:737)
        at org.restlet.routing.Filter.doHandle(Filter.java:156)
        at org.restlet.routing.Filter.handle(Filter.java:203)
        at org.restlet.routing.Filter.doHandle(Filter.java:156)
        at org.restlet.routing.Filter.handle(Filter.java:203)
        at org.restlet.routing.Filter.doHandle(Filter.java:156)
        at org.restlet.routing.Filter.handle(Filter.java:203)
        at org.restlet.routing.Filter.doHandle(Filter.java:156)
        at org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:151)
        at org.restlet.routing.Filter.handle(Filter.java:203)
        at org.restlet.routing.Filter.doHandle(Filter.java:156)
        at org.restlet.routing.Filter.handle(Filter.java:203)
        at org.restlet.engine.ChainHelper.handle(ChainHelper.java:111)
        at org.restlet.engine.application.ApplicationHelper.handle(ApplicationHelper.java:72)
        at org.restlet.Application.handle(Application.java:388)
        at org.restlet.routing.Filter.doHandle(Filter.java:156)
        at org.restlet.routing.Filter.handle(Filter.java:203)
        at org.restlet.routing.Router.doHandle(Router.java:497)
        at org.restlet.routing.Router.handle(Router.java:737)
        at org.restlet.routing.Filter.doHandle(Filter.java:156)
        at org.restlet.routing.Filter.handle(Filter.java:203)
        at org.restlet.routing.Router.doHandle(Router.java:497)
        at org.restlet.routing.Router.handle(Router.java:737)
        at org.restlet.routing.Filter.doHandle(Filter.java:156)
        at org.restlet.routing.Filter.handle(Filter.java:203)
        at org.restlet.engine.ChainHelper.handle(ChainHelper.java:111)
        at org.restlet.Component.handle(Component.java:387)
        at org.restlet.Server.handle(Server.java:488)
        at org.restlet.engine.ServerHelper.handle(ServerHelper.java:71)
        at org.restlet.engine.http.HttpServerHelper.handle(HttpServerHelper.java:150)
        at org.restlet.ext.servlet.ServerServlet.service(ServerServlet.java:1037)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:279)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.jav
a:515)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
2011-08-22 08:39:33 org.restlet.engine.log.LogFilter afterHandle
INFO: 2011-08-22        08:39:33        127.0.0.1       michal  127.0.0.1       8080    GET     /act
iviti-rest/service/form/3920/properties -       500     486     0       31      http://localhost:808
0       curl/7.20.1 (i686-pc-cygwin) libcurl/7.20.1 OpenSSL/0.9.8r zlib/1.2.5 libidn/1.18 libssh2/1.
2.5     -

I tried on Tomcat 6.0.32, 6.0.33, 7.0.20 and the problem occurs.
Activiti 5.7.

Could you help me with that?
Thanks!
3 REPLIES 3

frederikherema1
Star Contributor
Star Contributor
What properties does the task exactly have (keys + values) you were trying to get?

mprzycho
Champ in-the-making
Champ in-the-making
Process definition looks like that:



<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="FormPropertiesTest" name="FormPropertiesTest">
    <documentation>Place documentation for the 'FormPropertiesTest' process here.</documentation>
    <startEvent id="startevent1" name="Start"></startEvent>
    <endEvent id="endevent1" name="End"></endEvent>
    <userTask id="usertask1" name="User Task" activiti:assignee="kermit" activiti:formKey="test.form">
      <extensionElements>


        <activiti:formProperty id="name" name="name" type="string" required="true" readable="true" writable="true"></activiti:formProperty>


      </extensionElements>
    </userTask>
    <sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
    <sequenceFlow id="flow2" name="" sourceRef="usertask1" targetRef="endevent1"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_FormPropertiesTest">
    <bpmndi:BPMNPlane bpmnElement="FormPropertiesTest" id="BPMNPlane_FormPropertiesTest">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35" width="35" x="110" y="180"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35" width="35" x="380" y="200"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
        <omgdc:Bounds height="55" width="105" x="211" y="160"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="145" y="197"></omgdi:waypoint>
        <omgdi:waypoint x="263" y="215"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="316" y="187"></omgdi:waypoint>
        <omgdi:waypoint x="380" y="217"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

and the problem occurs. When I did couple of changes it worked:

I had to add script before this task and initialize variable, e.g. nameVar.
then I set expression of this task to "${nameVar}".
Now the proper value was returned.


<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="FormPropertiesTest" name="FormPropertiesTest">
    <documentation>Place documentation for the 'FormPropertiesTest' process here.</documentation>
    <startEvent id="startevent1" name="Start"></startEvent>
    <endEvent id="endevent1" name="End"></endEvent>
    <userTask id="usertask1" name="User Task" activiti:assignee="kermit" activiti:formKey="test.form">
      <extensionElements>

        <activiti:formProperty id="name" name="name" type="string" expression="${nameVar}" required="true" readable="true" writable="true"></activiti:formProperty>

      </extensionElements>
    </userTask>
    <sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="scripttask1"></sequenceFlow>
    <sequenceFlow id="flow2" name="" sourceRef="usertask1" targetRef="endevent1"></sequenceFlow>
    <scriptTask id="scripttask1" name="Script Task" scriptFormat="javascript">

      <script><![CDATA[execution.setVariable("nameVar", "")]]></script>

    </scriptTask>
    <sequenceFlow id="flow3" name="" sourceRef="scripttask1" targetRef="usertask1"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_FormPropertiesTest">
    <bpmndi:BPMNPlane bpmnElement="FormPropertiesTest" id="BPMNPlane_FormPropertiesTest">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35" width="35" x="110" y="180"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35" width="35" x="380" y="200"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
        <omgdc:Bounds height="55" width="105" x="211" y="160"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="scripttask1" id="BPMNShape_scripttask1">
        <omgdc:Bounds height="55" width="105" x="190" y="260"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="127" y="215"></omgdi:waypoint>
        <omgdi:waypoint x="190" y="287"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="316" y="187"></omgdi:waypoint>
        <omgdi:waypoint x="380" y="217"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="295" y="287"></omgdi:waypoint>
        <omgdi:waypoint x="263" y="215"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>


Is it neccessary to both initialize variables (this way or by passing it through start step) and declare task formProperties to get this service done?

frederikherema1
Star Contributor
Star Contributor
If you set the variable attr readable to "true", the variable SHOULD exist when the task props are fetched, it expect a variable with that name…