[jboss-user] [jBPM] - jBPM 4.3 starting a sub-process after a state node will fail

Huisheng Xu do-not-reply at jboss.com
Sat Apr 3 00:27:24 EDT 2010

Huisheng Xu [http://community.jboss.org/people/rebody] replied to the discussion

"jBPM 4.3 starting a sub-process after a state node will fail"

To view the discussion, visit: http://community.jboss.org/message/535446#535446

Hi Tun,

  I think I have found the reason of this problem. In fact, I just know the possible reason, still don't know why it appeared.

  As I said at above, I found in my test case there is no invoking operation to get next id for SUB process. So I guess that because I invoke both startProcessIntanceByKey() and signalExecutionById() methods in the same JVM, the id cache in DatabaseDbidGenerator could supply for both of them.

  Next step, I seperate these two methods, first invok startProcessInstanceByKey(), then shutdown the jvm and instance ProcessEngine again, then invoke signalExecutionById(). At this time I can see AcquireDbidBlockCmd have bean invoked twice, but there is still no exception occured.

  Now I can tell the reason that caused this problem. When we use 'sub-process' activity, it will create a ProcessInstance and let it begin to run. This step, the Super ProcessInstance and Sub ProcessInstance will create bi-direction relationship, we should note, at this time, the Sub ProcessInstance still have no ID, so next step pvm will try to generate a id for Sub ProcessInstance. PVM will execute the AcquireDbidBlockCmd to get the next id. It will invoke the DatabaseDbidGenerator to get the next, DatabaseDbidGenerator at first will check the cache, if the cache still have enough id, it will increment cache and return next id directly. If the cache if overflow, it will try to get next id from Database.*Please pay attension*, it will create a new session and start a new transition to do this. So whether it execute flush() won't cause exception. The cause of exception is you are using a same session both outside and inside when DatabaseDbidGenerator try to fetch next id from Database, at that time, outside session still hold Super ProcessInstance and Sub ProcessInstance, and Sub ProcessInstance still have no ID, if the flush() being invoked, hibernate will try to store unsaved Super ProcessInstance and Sub ProcessInstance into Database, but as we know, the Sub ProcessInstance have no ID and can't save in database at this time, So an exception has been thrown.

  I try this test case in both ProcessEngine and SpringEngine, both of them were succeed. So I can tell you that "the default configuration in jBPM distribution is correct." You can find two CommandService in jbpm.tx.hibernate.xml and jbpm.tx.spring.xml. The CommandService named newTxRequiredCommandService is used to create a new session when the DatabaseDbidGenerator try to get next id from database.

  I guest maybe you changed the default configuration and remove the newTxRequiredCommandService, and this caused the exception. I suggest you recheck your configuration, make sure there is newTxRequiredCommandService configured correctly. If the problem still can't sovled, you could look for logging to find whether the new session has created normally when DatabaseDbidGenerator try to get next id from Database.



Reply to this message by going to Community

Start a new discussion in jBPM at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100403/76d87d08/attachment.html 

More information about the jboss-user mailing list