Not able to restart externally terminated process instance

Please find the below details.

Rest API : https://locahost:8082/osmapplication/engine-rest/process-definition/osmapplication:3:f4af6b2d-e938-11ec-b64d-9af2fbbd93cf/restart

Request :
{
“instructions”: [
{
“type”: “startBeforeActivity”,
“activityId”: “Gateway_1m0dfee”
}
],
“initialVariables”: true,
“skipCustomListeners”: true,
“withoutBusinessKey”: false,
“historicProcessInstanceQuery”: {
“processDefinitionId”: “osmapplication:3:f4af6b2d-e938-11ec-b64d-9af2fbbd93cf”,
“processInstanceBusinessKey”: “152127495”
}
}

Response :

{
“type”: “ProcessEngineException”,
“message”: “Unknown property used in expression: ${flow2required}. Cause: Cannot resolve identifier ‘flow2required’”
}

I have tried with initialVariables options true and false.

Please let me know what need to be done to restart the process

Hi @nagendrakmt,
the error indicates that the variable flow2required (which is used inside your arc expression) is not set.
Can you confirm whether the variable exists in your cancelled instance?

Furthermore, there are some small improvements possible to the diagram:

  • The first XOR gateway has no function and may be removed
  • The OR gateway may start a parallel flow, which is merged by an XOR gateway, so the end event is potentially reached twice. If flow1 and flow2 are exclusive, I’d use an XOR split. If not, I either synchronize the execution via an OR join or use two end events (one after each call activity).
1 Like

Couly you please let me know where i can check variable existed or not. I am able to see the variable in camunda cockpit as part of main process.

Regards,
Nagendra

You can get all variables of your cancelled instance via the Rest API: http://localhost:8082/osmapplication/engine-rest/history/variable-instance?processInstanceId=ID_of_your_instance

Can you post the output?
When restarting an instance with "initialVariables":false, all the variables of the cancelled instance should be there upon restart.

Can you post the output?

[

{
    "type": "Boolean",
    "value": true,
    "valueInfo": {},
    "id": "36b6b3e6-3404-11ed-ad8c-54e1add97ccb",
    "name": "flow2required",
    "processDefinitionKey": "osmapplication",
    "processDefinitionId": "osmapplication:10:244e31f1-2463-11ed-9c25-54e1add97ccb",
    "processInstanceId": "315ec05a-3404-11ed-ad8c-54e1add97ccb",
    "executionId": "315ec05a-3404-11ed-ad8c-54e1add97ccb",
    "activityInstanceId": "315ec05a-3404-11ed-ad8c-54e1add97ccb",
    "caseDefinitionKey": null,
    "caseDefinitionId": null,
    "caseInstanceId": null,
    "caseExecutionId": null,
    "taskId": null,
    "errorMessage": null,
    "tenantId": "osmapp",
    "state": "CREATED",
    "createTime": "2022-09-14T10:07:02.081+0200",
    "removalTime": null,
    "rootProcessInstanceId": "315ec05a-3404-11ed-ad8c-54e1add97ccb"
}

]

When restarting an instance with "initialVariables":false , all the variables of the cancelled instance should be there upon restart.

When i restart instance with initialVariables":false below error showing
{
“type”: “NullValueException”,
“message”: “condition expression returns null: result is null”
}

Good. This means all required variables exist, but a boolean expression evaluates to null.
Let’s assume Camunda works right. Do you have another condition, i.e., after the first XOR or leading to flow1 that may evaluate to null instead of true or false?

Yes I have default expression as true.

I tried to replicate the issue.
Since I do not know the processes linked to your call-activitites, I used the following model, which resembles your process flow: process.bpmn (9.5 KB)
As suggested earlier, I replaced the OR-Gateway with a construct of AND and XOR gateways — now, it’s clear from the diagram, that flow 1 will always be executed and flow 2 is optional.

  1. I started a process instance setting flow2required=true.
  2. I completed validate request.
  3. I cancelled the process instance.
  4. I restarted the process before the and gateway using the following request:
{
"instructions": [
  {
    "type": "startBeforeActivity",
    "activityId": "Gateway_1xcxbwu"
  }],
  "initialVariables": false,
  "skipCustomListeners": true,
  "withoutBusinessKey": true,
  "historicProcessInstanceQuery": {
    "processInstanceId": "bfe73d32-341a-11ed-bcb4-84a9385a77fb"
  }
}

The process was restarted without an error.
I assume that error is hidden somewhere, maybe in the processes that you call, maybe in the properties of your call activity.

1 Like

Hi Stephan,

I have done the required changes in HTTP request jon.

{
“instructions”: [
{
“type”: “startAfterActivity”,
“activityId”: “Gateway_1m0dfee”
}
],
“initialVariables” : true,
“skipCustomListeners” : true,
“withoutBusinessKey” : false,
“historicProcessInstanceQuery”: {
“processDefinitionId”: “osmapplication:3:f4af6b2d-e938-11ec-b64d-9af2fbbd93cf”,
“processInstanceBusinessKey” : “152127495”,
“processInstanceIds”: [
“78c9762f-eb81-11ec-b64d-9af2fbbd93cf”
],
“variables”: [

{
  "name": "flow2variable",
  "value": false
}
]

}
}

When i try with this I am getting. Attached the same

{

"type": "NullPointerException",
"message": null

}

Given the information that you provide, I cannot determine the problem.
Is this the full-stack trace?
Also consider the semantics of your REST request:
You want to restart an instance with ID 78c9762f-eb81-11ec-b64d-9af2fbbd93cf if and only if flow2variable is false.
Upon the restart, your request discards all but the initial variables (initialVariables:true). Is this what you intended?

You want to restart an instance with ID 78c9762f-eb81-11ec-b64d-9af2fbbd93cf if and only if flow2variable is false .

Yes stephan I want to start the process instance ID 78c9762f-eb81-11ec-b64d-9af2fbbd93cf with flow2variable as false.

Upon the restart, your request discards all but the initial variables (initialVariables:true ). Is this what you intended? I have tried with both false and true

Attaching the complete exception stacktrace

2022-09-19 10:56:21.710 WARN 1 — [nio-8080-exec-6] org.camunda.bpm.engine.rest.exception : ENGINE-REST-HTTP500 java.lang.NullPointerException
at org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto.applyFilters(HistoricProcessInstanceQueryDto.java:497)
at org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto.applyFilters(HistoricProcessInstanceQueryDto.java:45)
at org.camunda.bpm.engine.rest.dto.AbstractQueryDto.toQuery(AbstractQueryDto.java:104)
at org.camunda.bpm.engine.rest.sub.repository.impl.ProcessDefinitionResourceImpl.createRestartProcessInstanceBuilder(ProcessDefinitionResourceImpl.java:410)
at org.camunda.bpm.engine.rest.sub.repository.impl.ProcessDefinitionResourceImpl.restartProcessInstance(ProcessDefinitionResourceImpl.java:383)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:124)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:167)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$VoidOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:159)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:79)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:469)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:391)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:80)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:255)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)
at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
at org.glassfish.jersey.internal.Errors.process(Errors.java:244)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:234)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:680)
at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:394)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:366)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:319)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.camunda.bpm.engine.rest.filter.CacheControlFilter.doFilter(CacheControlFilter.java:45)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.camunda.bpm.engine.rest.filter.EmptyBodyFilter.doFilter(EmptyBodyFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:204)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:183)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:764)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:888)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:830)

Regards,
Nagendra

Thanks for the additional information.

Based on your StackTrace, I locate the problem in the historicInstanceQuery. Please note, that this is a query. The variables array does not mean “we set flow2variable to false” it means, we searching for an historic instance where the variable flow2variable has the value false. Additionally, you filter using the process definition ID, the process instance ID, and the process instance business key: Try to use only the process instance Id. Since this ID is unique all other information in the query should be obsolete.

If you want to use more parameters, check out the corresponding documentation. The variables array, expects object with three fields: the variable name, an operator, and a value. So consider this:

"variables": [{
  "name": "flow2variable",
  "operator": "eq",
  "value": false
}]
1 Like

Hi Stephan,

Issue got resolved. Thaks for your help.

Regards,
Nagendra.