-
1. Re: jBPM and HttpSession
aymanson Nov 1, 2005 1:50 AM (in response to ashkumar)You get the task in 1 page. save the task instance Id in session.
Then use pSession.getTaskMgmtSession().loadTaskInstance(pTaskInstanceId) to get back the task instance. -
2. Re: jBPM and HttpSession
ashkumar Nov 1, 2005 11:00 AM (in response to ashkumar)Hi,
I can get back the taskInstance object without any problems. But when we go to actually execute that task, it needs the session that created this taskInstance in the first place.
How do we put this jBPMSession object in the HTTPSession when it is not serializable? The problem is only with this JBPMSession object.
Thanks. -
3. Re: jBPM and HttpSession
julian_k Nov 1, 2005 7:45 PM (in response to ashkumar)You should create a new JbpmSession object. There is no need to use the original session that created the TaskInstance. It is much like a database conncetion, you do not keep it open across multiple requests nor do you put it in the HttpSession.
Regards,
Julian -
4. Re: jBPM and HttpSession
ashkumar Nov 2, 2005 5:57 PM (in response to ashkumar)I have verified this several times before. Please look at the code below.
JbpmSession session = jbpmSessionFactory.openJbpmSession();
tasks = sa.getTaskInstances (session, "davids-fl-state");
session.close();
JbpmSession session1 = jbpmSessionFactory.openJbpmSession();
iter = tasks.iterator();
while (iter.hasNext())
{
sa.SubmitStateEnrollmentApproval("davids-fl-state", session1, (TaskInstance)iter.next());
}
So, I am creating the tasks with one session and executing them with another session. I get the exception below.
Exception in thread "main" 16:37:38,873 ERROR LazyInitializationException : failed to lazily initialize a collection of role: org.jbpm.taskmgmt.def.Task.events - no session or session was closed
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: org.jbpm.taskmgmt.def.Task.events - no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:191)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:183)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:48)
at org.hibernate.collection.PersistentMap.get(PersistentMap.java:123)
at org.jbpm.graph.def.GraphElement.getEvent(GraphElement.java:52)
at org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.java:144)
at org.jbpm.graph.def.GraphElement.fireEvent(GraphElement.java:133)
at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:318)
at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:293)
------------------
IF I do not close the session as in the code above, I still get an exception
-------------------
16:50:24,287 ERROR GraphSession : org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
Exception in thread "main" java.lang.RuntimeException: couldn't save process instance 'org.jbpm.graph.exe.ProcessInstance@74f5a4bc'
at org.jbpm.db.GraphSession.saveProcessInstance(GraphSession.java:209)
at EnrollmentTest.SubmitStateEnrollmentApproval(EnrollmentTest.java:205)
at EnrollmentTest.main(EnrollmentTest.java:338)
----------------------------------
There is quite certainly some relationship between a task and the session that created it. The task seeems to keep a reference to the session that created it. This makes the design of a web application fairly complicated due to having to store JbpmSession in HttpSession.
Thanks and regards, -
-
6. Re: jBPM and HttpSession
aguizar Nov 2, 2005 9:49 PM (in response to ashkumar)Effectively, a persistent object is bound to the session that loaded or saved it. To use it in a different session, you must reattach the object. See section 12.3.3 Detached objects of the Hibernate users guide for a description.
Note that an object cannot be attached to more than one session. In order for this solution to work, the original session must be closed.