JBoss Community

Lazy loading of sub-process

created by Fabio Spiga in jBPM - View the full discussion

Hi all,

I have a problem in getting a subprocess reference from the main process instance.

My code is the following:

 

ProcessInstance processInstance = executionService.startProcessInstanceByKey("RPG");
ExecutionImpl ex_pi = ((ExecutionImpl) processInstance).findActiveExecutionIn("integr_doc");
ProcessInstance sub_pi = ex_pi.getSubProcessInstance();   
assertNotNull(sub_pi);

 

where "integr_doc" is the name of a subprocess

 

The call to "getSubProcessInstance()" is succesful, but the object "sub_pi" throws an Exception if I try to read any property of it because it was lazy initialized and the session has been closed.

 

I get the following exception:

 

org.hibernate.LazyInitializationException <init>
GRAVE: could not initialize proxy - no Session
org.hibernate.LazyInitializationException: could not initialize proxy - no Session

 

In order to resolve this problem, I have found only one solution: modifying the "jbpm.execution.hbm.xml" in "jbpm.jar" by adding the attribute "lazy=false" to the foreign-key "FK_EXEC_SUBPI".

This is a very awful solution because I had to modify the original library!

If I put a copy of "jbpm.execution.hbm.xml" in the classpath (in order to not modify the original library), JBoss AS try to map jBPM entity beans before the related classes are loaded, so it fails to start.

 

Is there a way to get a subprocess instance more gracefully?

 

Thank you in advance and sorry for my long thread...

 

Fabio

Reply to this message by going to Community

Start a new discussion in jBPM at Community