Hello,
I am having trouble understanding the best time and place to persist my Process
Instance when tasks are involved.
I have a servlet that creates a new process instance from a definition which is
retrieved via a user managed transaction:
| JbpmSession session =
JbpmSessionFactory.getInstance().openJbpmSessionAndBeginTransaction()
| ProcessDefinition def = session.getGraphSession().
| findLatestProcessDefinition(?DEF_NAME?);
| ProcessInstance pi = new ProcessInstance(def);
| pi.signal();
| session.commitTransactionAndClose();
|
The process instance then arrives at a task node, with an AssignmentHandler
associated, which does the following:
| public void assign( Assignable assignable, ExecutionContext context ){
| assignable.setActorId(?myUsername?);
| context.getTaskInstance().start();
| JbpmSession session =
JbpmSessionFactory.getInstance().openJbpmSessionAndBeginTransaction();
| session.getGraphSession().saveProcessInstance(context.getProcessInstance());
| session.commitTransactionAndClose();
| }
|
However it is failing at the
session..getGraphSession().saveProcessInstance(context.getProcessInstance());
Line with the exception:
Illegal attempt to associate a collection with two open sessions
Can you please explain what I am doing wrong here? I have arrived at this
junction after trying many different options and I cant think of any other way.
I have the following questions:
| 1.) can I start the transaction instance in the assignment handler? if not,
where do I start it?
| 2.) do I save the process instance in the assignment handler (or from any
other class that is part of the process instance execution)? If not, how and
where do I carry out the persistence after the process instance is in a wait
state? If so, why am i getting the above error when saving?
| 3.) currently I have 2 JbpmSessionFactorys. 1 for classes not involved in
the process instance (servlets etc) and 1 for classes involved in the process
instance (actions, assignment handlers etc). How can I have only 1 session
factory thats used by all classes? I tried using JNDI, but we are using Tomcat
as our application server, and its Initial Context is read only, so I cant
place the session factory in there.
|
| Thanks for your help.
|
| toby
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3915561#3915561
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3915561
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user