cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot get process execution variables after the process is completed

rahult
Champ in-the-making
Champ in-the-making
The scenario is a little different from one mentioned above.

Acitivi verision : 5.12.1

Here is my code snippet.

Map var = new HashMap();
var.put("workorderrequest", payload);
var.put("workOrderResponse", response);
ProcessInstance pi = runtime.startProcessInstanceByKey("getWorkOrder", var);
response = (GetWorkOrderDetailsResponseType) runtime.getVariable(pi.getProcessInstanceId(),"workOrderResponse");

At the time of runtime.getVariable, my process is already complete and successfull. I'm not able to access the process level parameters from it. I m running activiti on weblogic 10.3.4 with oracle 11g database with spring configuration.

It give me the following exception.

DFLTLOG> DEBUG 19:32:31 org.springframework.jdbc.datasource.SimpleDriverDataSource> Creating new JDBC Driver Connection to [jdbcSmiley Surprisedracle:thin:@10.100.10.207:1521:sidev11g]
07:32:31,503 [[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'] ERROR org.activiti.engine.impl.interceptor.CommandContext - Error while closing command context
org.activiti.engine.ActivitiObjectNotFoundException: execution 301 doesn't exist
at org.activiti.engine.impl.cmd.GetExecutionVariableCmd.execute(GetExecutionVariableCmd.java:54)
at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:61)
at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
at org.activiti.engine.impl.RuntimeServiceImpl.getVariable(RuntimeServiceImpl.java:118)
at com.sigma.omp.extinterfaces.oms.WorkOrderOMSAmdocsV1PortTypeImpl.getWorkOrderDetails(WorkOrderOMSAmdocsV1PortTypeImpl.java:91)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:92)
at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:74)
at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:151)
at com.sun.xml.ws.server.sei.EndpointMethodHandlerImpl.invoke(EndpointMethodHandlerImpl.java:268)
at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:100)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:866)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:815)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:778)
3 REPLIES 3

trademak
Star Contributor
Star Contributor
You should use the HistoryService to get information about completed process instances.

Best regards,

rahult
Champ in-the-making
Champ in-the-making
Thanks a lot.
I have been using history service to get the information.
However i was wondering if i could get the information from process instance runtime service itself in order to avoid a DB call.

Is there any another approch that can be used to avoid this DB call like a distributed cache?

frederikherema1
Star Contributor
Star Contributor
Getting variables from a process-instance always requires a call to the runtimeService. When you're inside activiti-context (eg. JavaDelegate in service-task or DelegateExecution in task/execution-listeners) you can fetch the variables from the DelegateExecution. You should, for example, add a execution listener on process-end and write the variables to some kind of distributed cache in this listener. The listener will be called RIGHT BEFORE the process ends. However, this only works for processes that have been complete while the cache was running.

Don't really see why a call to the DB should be a problem for completed processes?