ProcessAPIImpl updateActivityInstanceVariables values of the parameter variables are lost

Description

ProcessAPIImpl updateActivityInstanceVariables values of the parameter variables are lost

Environment

None

External Link

ProcessAPIImpl updateActivityInstanceVariables values of the parameter variables are lost

Workaround

None

Activity

Show:
Ingrid Carolina Mendoza Chuecas
June 5, 2019, 10:23 PM

The error is:

POST http://localhost:8080/bonita/serverAPI/org.bonitasoft.engine.api.ProcessAPI/updateActivityInstanceVariables HTTP/1.1

2019-05-23 16:47:01,406 ERROR c.e.b.s.BPMService:206 - Exception org.bonitasoft.engine.exception.UpdateException: USERNAME=usuario | Some data does not exists, wanted to update [param1, param2] but there is only [] at org.bonitasoft.engine.api.HTTPServerAPI.invokeMethod(HTTPServerAPI.java:128) at org.bonitasoft.engine.api.impl.ClientInterceptor.invoke(ClientInterceptor.java:86) at com.sun.proxy.$Proxy6.updateActivityInstanceVariables(Unknown Source) at com.example.bonita.service.BPMServiceImpl.updateProcess(BPMServiceImpl.java:144) at com.example.bonita.service.BPMServiceImpl.executeBPMTask(BPMServiceImpl.java:221) at com.example.bonita.service.BPMService.obtenerToken(BPMService.java:197) at

Antoine Mottier
June 6, 2019, 7:45 AM

Can you share your project (as .bos file) to reproduce the issue?

How do you figure out that the variable are "lost"?

Also can you clarify if you declared if you are trying to update:

  1. A process parameter (Select process and go in "Data" -> "Parameters" tab)

  2. A process variable (Select process and go in "Data" -> "Pool variables" tab -> "Process variables" section)

  3. A step variable (Select task and go in "Data" -> "Local variables" tab)

And give the name and type of the variables.

Thanks

Ingrid Carolina Mendoza Chuecas
June 6, 2019, 1:50 PM
Edited

Hi Antoine, my .bos cannot share with you for terms confidentiality, but this works OK without Java invocation. I'm trying to set from Java the contract variables or input variables in this secction.

In Java, I'm sending a JSON:

{"activity": "greeting","instanceId": 1234567,"param1": "Hello","param2": "World"}

And my code in Java is:

~boolean resolved = false;
String result = "";

APISession apisession = bpmService.createLogin(username, password) ;

pendingTasks.clear() ;
pendingTasks = processAPI.getPendingHumanTaskInstances(apiSession.getUserId(), 0, 30, null) ;

for (Iterator<HumanTaskInstance> i = pendingTasks.iterator(); i.hasNext() ; ) {
HumanTaskInstance item = i.next();
taskid = item.getId();
processAPI.updateActivityInstanceVariables(taskid, jsonVariables);

resolved = true;
break;
}~

And throws this exception:

~ERROR c.e.b.s.BPMService:206 - Exception org.bonitasoft.engine.exception.UpdateException: USERNAME=usuario | Some data does not exists, wanted to update [param1, param2] but there is only [] at org.bonitasoft.engine.api.HTTPServerAPI.invokeMethod(HTTPServerAPI.java:128) at org.bonitasoft.engine.api.impl.ClientInterceptor.invoke(ClientInterceptor.java:86) at com.sun.proxy.$Proxy6.updateActivityInstanceVariables(Unknown Source) at com.example.bonita.service.BPMServiceImpl.updateProcess(BPMServiceImpl.java:144) at com.example.bonita.service.BPMServiceImpl.executeBPMTask(BPMServiceImpl.java:221)
~

Thanks

Antoine Mottier
June 6, 2019, 2:50 PM

If you are using Bonita Java client library the HTTP call to the API is generated for you. It will not call the Bonita Engine REST API but a different set of APIs documented in the Javadoc of the client library. Data in this HTTP call use Java serialization and are not sent as JSON.

Alternatively you can use Bonita Engine REST API. Data sent in REST API call are serialized as JSON. You can perform REST API call from Java applications.

So you you have two options: the Java client library or the REST API.

If you use the Java client library, to execute the task and provide some contract values you need to use ProcessRuntimeAPI executeUserTask method

I understand that you might not be able to share the content of your application due to confidentiality issue. In such situation can you share a small example to reproduce the issue? An alternative would be to reach out to Bonitasoft commercial support under an NDA.

I'll close this issue because it's a misunderstanding in the usage of the API. If you need some help you can post your question on the community website Q&A section.

Assignee

Antoine Mottier

Reporter

Ingrid Carolina Mendoza Chuecas

Affects versions

Reference

None

Fix versions

Configure