-
1. Re: Variables from ended process ...
rebody Jun 14, 2010 4:25 PM (in response to newbeewan)Hi Jaber,
The history variable feature has not implemeneted yet in jbpm 4.3. If you want to store history variable after proces have been deleted, you must store them into your table.
Maciej have implemented this feature in the current trunk. We could try this feature after jbpm 4 releasing.
But I don't think store all of process variables is a good idea. If you want more controlling for the variable data, please create your table and maintain them in your own tables. Please consider about it.
-
2. Re: Variables from ended process ...
newbeewan Jun 15, 2010 5:42 AM (in response to rebody)Hi,
I'm agree with out, it is not a good practice to store variables after the end of the process instance. Now Jbpm is use in my current project to replace some paper docs.
Currently, my document is the process instance because all task validation are part of the document and to generate the final pdf, I'm using data from the process (task, assignee, complete date...) and variables which are populate by users.
Variables are mainly used to create a file or to show them in a jsf page... and there are no other usage !
Is it possible to set programmatically an event listener for a process instance ? or is jbpm 4.4 is enough stable for development usage ?
Regards
-
3. Re: Variables from ended process ...
rebody Jun 16, 2010 2:56 AM (in response to newbeewan)Hi jaber,
Is it possible to set programmatically an event listener for a process instance ?
Because execution didn't implement the ObservableElement interface, so we cannot set an event listener to it. If you want to get some history event, you could use History Listener Chain. Please refer here : http://docs.jboss.com/jbpm/v4/devguide/html_single/#d0e1169
is jbpm 4.4 is enough stable for development usage ?
Since we had resovled 90+ issues, I want to believe jbpm 4.4 is stable enough. If you have any ideas for the next version of jbpm4, please tell us, Thank you very much.
-
4. Re: Variables from ended process ...
newbeewan Jun 17, 2010 10:16 AM (in response to rebody)Hi,
I'm trying to use history varaibles in jbpm 4.4 and I encounter an NPE :
2010-06-17 15:56:07,742 [INFO ] org.jbpm.pvm.internal.svc.DefaultCommandService 54 - exception while executing command org.jbpm.pvm.internal.cmd.GetHistoryVariablesCmd@194d4313 java.lang.NullPointerException at org.jbpm.pvm.internal.cmd.GetHistoryVariablesCmd.execute(GetHistoryVariablesCmd.java:60) at org.jbpm.pvm.internal.cmd.GetHistoryVariablesCmd.execute(GetHistoryVariablesCmd.java:40) at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42) at org.jbpm.pvm.internal.tx.SpringCommandCallback.doInTransaction(SpringCommandCallback.java:45) at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130) at org.jbpm.pvm.internal.tx.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:53) at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53) at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40) at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:56) at org.jbpm.pvm.internal.svc.HistoryServiceImpl.getVariables(HistoryServiceImpl.java:97)
Is there something particular to configure to make it available ?
I'm using the executionService method executionService.createVariables(executionId, myVariables, true); to activate the history on the current process variable, is it enough ?
Regards
-
5. Re: Variables from ended process ...
swiderski.maciej Jun 17, 2010 11:41 AM (in response to newbeewan)Could you provide a bit more details about how you create and how you access history variable?
One thing that comes to my mind directly is that you shall use processInstanceId and not executionId (sometimes it is the same) to get history variables.
-
6. Re: Variables from ended process ...
newbeewan Jun 17, 2010 12:01 PM (in response to swiderski.maciej)Hi,
To get history variable i'm using that code using the processInstanceId :
public Map<String, Object> getHistoryProcessInstanceVariable(String processInstanceId) { Set<String> variableNames = historyService.getVariableNames(historyProcessInstanceId); return historyService.getVariables(processInstanceId, variableNames); }
In my test :
HistoryProcessInstance historyProcessInstance = processInstanceService.getHistoryProcessInstanceById(processInstance.getId()); assertEquals(historyProcessInstance.getState(), "ended" ); Map<String, Object> historyVariables = processInstanceService.getHistoryProcessInstanceVariable(historyProcessInstance.getProcessInstanceId()); assertNotNull(historyVariables); assertFalse(historyVariables.isEmpty());
In my service, to create my variables (I change the code to be sure that I'm using the processInstanceId) :
String processInstanceId = executionService.findProcessInstanceById(taskService.getTask(taskId).getExecutionId()).getId(); executionService.createVariables(processInstanceId, variables, true);
But nothing better
Any Idea ?
-
7. Re: Variables from ended process ...
swiderski.maciej Jun 17, 2010 12:20 PM (in response to newbeewan)Could you please provide a unit test for this?
I have tried to reproduce it but no luck unless processInstanceId is wrong or list of variable names gives as argument to getVariables method is null.
-
8. Re: Variables from ended process ...
newbeewan Jun 17, 2010 4:24 PM (in response to swiderski.maciej)No pb, I will create a fresh unit test tomorrow morning (for me), perhaps I will find my misconfiguration !
Regards
-
9. Re: Variables from ended process ...
newbeewan Jun 18, 2010 9:46 AM (in response to swiderski.maciej)Hi,
I don't undersand the trouble !
I create a test for history variable and all works as expected (including setting non history variables and variable set by some eventlistener) !
In a real process, I've got that NPE !
2010-06-18 15:08:27,274 [INFO ] org.jbpm.pvm.internal.svc.DefaultCommandService 54 - exception while executing command org.jbpm.pvm.internal.cmd.GetHistoryVariablesCmd@70a6aa31
java.lang.NullPointerException
at org.jbpm.pvm.internal.cmd.GetHistoryVariablesCmd.execute(GetHistoryVariablesCmd.java:65)
at org.jbpm.pvm.internal.cmd.GetHistoryVariablesCmd.execute(GetHistoryVariablesCmd.java:37)
at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42)
at org.jbpm.pvm.internal.tx.SpringCommandCallback.doInTransaction(SpringCommandCallback.java:45)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
at org.jbpm.pvm.internal.tx.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:49)
at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53)
at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)
at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:56)
at org.jbpm.pvm.internal.svc.HistoryServiceImpl.getVariable(HistoryServiceImpl.java:90)So, I'm suspecting a missconfiguration, but I don't know where !
Regards
-
10. Re: Variables from ended process ...
newbeewan Jun 21, 2010 6:45 AM (in response to newbeewan)Hi,
Finally, I manage to solve it !
My test method was transactional by spring aspect (using @Transactional) and all process/task/history was executing into the same transaction (which is absolutly not the normal way the process execution in my application).
When I remove the transactional annotation, my test become green !
I can reproduce it with any test, but I don't understand why that happen !
If you think about an explanation, I will be happy !
Regards
-
11. Re: Variables from ended process ...
swiderski.maciej Jun 22, 2010 1:11 PM (in response to newbeewan)Unfortunately I am not spring expert but if you post here a test case to illustrate the problem I am sure someone will take a look at it.
-
12. Re: Variables from ended process ...
rebody Jun 23, 2010 1:19 AM (in response to newbeewan)Hi jaber,
I guess, If you used readOnly=true or UNSUPPORTED, then the transaction won't be committed to the database, so the process instance cannot be found later.
So If you could provide a whole project, we could investigate more clearly. Thank you very much.
-
13. Re: Variables from ended process ...
newbeewan Jun 23, 2010 6:13 AM (in response to rebody)I'm using transaction in unit test with rollbackOnly=false so, I hope it is enought to commit data
I'm suspecting some conflict between transaction from test and task execution and from automatic activities (java, mail and custom)...
I will try to reproduce it in a clean environment and if it does the same thing, I will send it to you.
Regards
-
14. Re: Variables from ended process ...
charles_a Jul 30, 2010 5:57 AM (in response to newbeewan)Hi Jaber,
we´re getting exactly the same error. We´re also using Spring integration and using transactions. We´re currently encapsulating our tests with a transaction to rollback the data later.
Of course, we could rearrange our tests in another way, but I see situations in our application where we also want this transactional behavior...
How do you deal with this error?
Cheers,
Charles