-
1. Re: failed to lazily initialize a collection of role: org.jbpm.pvm.internal.model.ExecutionImpl.variables, no session or session was closed
mwohlf Jul 9, 2010 8:20 AM (in response to felixkjose)Hi Felix,
you might need this in jbpm.cfg.xml:
[...]
<command-service name="newTxRequiredCommandService">
<retry-interceptor />
<environment-interceptor policy="requiresNew" />
<spring-transaction-interceptor policy="requiresNew" /></command-service>
<command-service name="txRequiredCommandService">
<retry-interceptor />
<environment-interceptor />
<spring-transaction-interceptor current="true" />
</command-service>[...]
also maybe your SpeaddWorkFlow.StartWorkFlow() method needs a @Transactional annotation?
and finally you can try to do whatever you do in line 245 of SpeaddWorkFlow.java within a command like described by HuiSheng in this thread:
processEngine.execute(new Command() {
public Object execute(Environment env) {
// do something.
return null;
}
}); -
2. Re: failed to lazily initialize a collection of role: org.jbpm.pvm.internal.model.ExecutionImpl.variables, no session or session was closed
felixkjose Jul 10, 2010 1:40 AM (in response to mwohlf)HI Michael,
Thank You for your reply. Even I am having the same configuration in my jbpm.cfg.xml file. Then I have tried with reinstantiate the ExecutionService factory as
executionService = processEngine.getExecutionService();
Then after that it starts working. Before I give the transaction management I was getting the lazyinitialization exception while trying to access the properties of the jbpm process variable objects. But after I configure the transaction management as follows:
<bean id="jbpmContextServiceTarget" class="com.collabera.poc.jbpm.impl.JBPMContextServiceImpl"
init-method="init">
<property name="processEngine">
<ref bean="processEngine" />
</property>
<property name="checking">
<ref bean="checking" />
</property>
<bean id="jbpmContextService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager"><ref bean="transactionManager"/></property>
<property name="target"><ref bean="jbpmContextServiceTarget"/></property>
<property name="transactionAttributes">
<props>
<prop key="deploy*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
And try to do a transition using executionService I am getting the exception saying that "
Exception in thread "main"
org.jbpm.api.JbpmException: execution ddrRequest.400008 does not exist
at org.jbpm.pvm.internal.cmd.SignalCmd.execute(
SignalCmd.java:58)
at org.jbpm.pvm.internal.cmd.SignalCmd.execute(
SignalCmd.java:35)
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:128)
I am getting this exception when I am using the ExecutionService instance to access the process instance.
In my analysis the problem is as the transaction is active and session is opened the JBPM4_EXECUTION table is not getting updated and the
executionService
.signalExecutionById(id, "analystResearch"); is trying to find the execution istance from table but it is not present. But my doubt is why it is not tring to pick it from session?
One main thing is this problem is occuring only when the JBPM process definition is having a <java> node with some arguments and if we change the variable/variables in that java class.
And one more doubt,
processEngine.execute(new Command() {
public Object execute(Environment env) {
// do something.
return null;
}
});
why do we need this?Can anybody please send me a solution for the same.
Thank you and regards,
Felix K Jose