[JBoss jBPM] - org.hibernate.SessionException: Session is closed! error on
by chrisrjcox
Hi,
I have an issue where I signal my token into the <<end-state>> node at the end of a process, then get a message org.hibernate.SessionException: Session is closed!
I have a class which signals a token to move the process from one <<task-node>> to the <<end-state>> node.
The <<end-state>> node has a action handler which is invoked on node-enter, once the token.signal(); is initiated {TAG 1} (from the <<task-node>> prior), this works fine. However once this action handler is complete {TAG 2}. And the token.signal(); is completed {TAG 3}. The token is now in the <<end-state>> {TAG 4} and the jbpmContext.close(); is completed [TAG 5]. Once the Context is closed and my class is finished (there is no more code to implement) {TAG 6} I receive a
org.hibernate.SessionException: Session is closed! stacktrace.
Below is a trace from the terminal.
| 15:24:03,054 INFO [STDOUT] PartTwoMDB: onMessage: Begining Token token = processInstance.getRootToken();
| 15:24:03,054 INFO [STDOUT] PartTwoMDB: onMessage: Completed Token token = processInstance.getRootToken();
| 15:24:03,054 INFO [STDOUT] PartTwoMDB: onMessage: Begining token.signal(); {TAG 1}
| 15:24:03,061 WARN [ProxyWarnLog] Narrowing proxy to class org.jbpm.graph.node.EndState - this operation breaks ==
| 15:24:03,068 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Begining jndi = new InitialContext(); THIS IS THE "SendMessageToQueueBackForPartOne" ACTION HANDLER WITHIN THE <<end-state>> {TAG 2}
| 15:24:03,069 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Completed jndi = new InitialContext();
| 15:24:03,069 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Begining conFactory = (ConnectionFactory)jndi.lookup('ConnectionFactory');
| 15:24:03,069 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Completed conFactory = (ConnectionFactory)jndi.lookup('ConnectionFactory');
| 15:24:03,069 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Begining connection = conFactory.createConnection();
| 15:24:03,089 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Completed connection = conFactory.createConnection();
| 15:24:03,089 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Begining session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
| 15:24:03,089 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Completed session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
| 15:24:03,089 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Begining Queue queue = (Queue) jndi.lookup('queue/jbpmQueueOne');
| 15:24:03,089 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Completed Queue queue = (Queue) jndi.lookup('queue/jbpmQueueOne');
| 15:24:03,090 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Begining producer = session.createProducer(queue);
| 15:24:03,090 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Completed producer = session.createProducer(queue);
| 15:24:03,090 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Begining ProcessInstance processInstance = context.getProcessInstance();
| 15:24:03,090 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Completed ProcessInstance processInstance = context.getProcessInstance();
| 15:24:03,090 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Begining Token token = context.getProcessInstance().getRootToken();
| 15:24:03,090 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Completed Token token = context.getProcessInstance().getRootToken();
| 15:24:03,090 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Begining ContextInstance contextInstance = (ContextInstance) processInstance.getInstance(ContextInstance.class);
| 15:24:03,090 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Completed ContextInstance contextInstance = (ContextInstance) processInstance.getInstance(ContextInstance.class);
| 15:24:03,091 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Begining processInstanceIDLong = (Long)contextInstance.getLocalVariable('distributedProcessID', token);
| 15:24:03,091 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Completed processInstanceIDLong = (Long)contextInstance.getLocalVariable('distributedProcessID', token);
| 15:24:03,091 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: processInstanceIDLong is ****209****
| 15:24:03,091 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Begining processInstanceID = processInstanceIDLong.longValue();
| 15:24:03,092 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Completed processInstanceID = processInstanceIDLong.longValue();
| 15:24:03,092 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Begining bandName = (String)contextInstance.getVariable('bandName', token);
| 15:24:03,092 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Completed bandName = (String)contextInstance.getVariable('bandName', token);
| 15:24:03,092 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: bandName is ****The Shockers****
| 15:24:03,092 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Begining DistributedObject distributedObject = new DistributedObject();
| 15:24:03,092 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Completed DistributedObject distributedObject = new DistributedObject();
| 15:24:03,093 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Begining distributedObject.processID = processInstanceID;
| 15:24:03,093 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Completed distributedObject.processID = processInstanceID;
| 15:24:03,093 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Begining distributedObject.processID = processInstanceID;
| 15:24:03,093 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Completed distributedObject.processID = processInstanceID;
| 15:24:03,093 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Begining XStream xstream = new XStream();
| 15:24:03,103 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Completed XStream xstream = new XStream();
| 15:24:03,104 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Begining xstream.alias('distributedObject', DistributedObject.class);
| 15:24:03,104 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Completed xstream.alias('distributedObject', DistributedObject.class);
| 15:24:03,104 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Begining String xml = xstream.toXML(distributedObject);
| 15:24:03,105 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Completed String xml = xstream.toXML(distributedObject);
| 15:24:03,105 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: XStreams has converted the distributedObject to the following xml<distributedObject>
| <processID>209</processID>
| <bandName>The Shockers</bandName>
| </distributedObject>
| 15:24:03,105 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Begining textMessage = session.createTextMessage(xml);
| 15:24:03,105 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Completed textMessage = session.createTextMessage(xml);
| 15:24:03,106 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Begining producer.send(textMessage);
| 15:24:03,108 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute: Completed producer.send(textMessage);
| 15:24:03,108 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute/finally: jndi != null: Begining jndi.close();
| 15:24:03,108 INFO [STDOUT] SendMessageToQueueBackForPartOne: execute/finally: jndi 1= null: Completed jndi.close();
| 15:24:03,108 INFO [STDOUT] *******************SendMessageToQueueBackForPartOne - COMPLETED ************************* HERE THE ACTION HANDLER HAS COMPLETED {TAG 2}
| 15:24:03,108 INFO [STDOUT] PartTwoMDB: onMessage: Completed token.signal(); {TAG 3}
| 15:24:03,108 INFO [STDOUT] PartTwoMDB: onMessage: Current Node EndState(end-state1) {TAG 4}
| 15:24:03,108 INFO [STDOUT] PartTwoMDB: onMessage(): Begining jbpmContext.close();
| 15:24:03,119 INFO [STDOUT] PartTwoMDB: onMessage(): Completed jbpmContext.close(); {TAG 5}
| 15:24:03,121 INFO [STDOUT] *******************PartTwoMDB - COMPLETED ************************* {TAG 6}
| 15:24:03,122 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_2] TwoPhaseCoordinator.beforeCompletion - failed for com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple@bfad6d
| org.hibernate.SessionException: Session is closed!
| at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:49)
|
If i manually move from the <<task-node>> to the <<end-state>> there is no error.
below is the code moving the token.
| package com.distributed.jbpm.mdb;
|
| import javax.ejb.MessageDriven;
| import javax.ejb.ActivationConfigProperty;
|
|
| import javax.jms.Message;
| import javax.jms.MessageListener;
| import javax.jms.TextMessage;
|
|
| import org.jbpm.JbpmConfiguration;
| import org.jbpm.JbpmContext;
|
| import org.jbpm.context.exe.ContextInstance;
| import org.jbpm.graph.exe.ProcessInstance;
| import org.jbpm.graph.exe.Token;
|
| import com.thoughtworks.xstream.XStream;
|
|
|
| @MessageDriven(activationConfig =
| {
| @ActivationConfigProperty(propertyName="acknowledgeMode", propertyValue = "Auto-acknowledge"),
| @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
| @ActivationConfigProperty(propertyName="destination", propertyValue="/queue/jbpmQueueTwo")
| })
|
| public class PartTwoMDB implements MessageListener
| {
| static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
|
| long distributedProcessInstanceID;
|
|
|
| public void onMessage(Message inMessage)
| {
| System.out.println("PartTwoMDB: onMessage: Started");
| TextMessage textMessage = null;
| try
| {
| if(inMessage instanceof TextMessage)
| {
| textMessage = (TextMessage) inMessage;
| System.out.println("PartTwoMDB: onMessage: Message received: "+ textMessage.getText());
|
| System.out.println("PartTwoMDB: onMessage: Begining XStream xstream = new XStream();");
| XStream xstream = new XStream();
| System.out.println("PartTwoMDB: onMessage: Completed XStream xstream = new XStream();");
|
| System.out.println("PartTwoMDB: onMessage: Begining xstream.alias('distributedObject', DistributedObject.class);");
| xstream.alias("distributedObject", DistributedObject.class);
| System.out.println("PartTwoMDB: onMessage: Completed xstream.alias('distributedObject', DistributedObject.class);");
|
| System.out.println("PartTwoMDB: onMessage: Begining String xml = textMessage.getText();");
| String xml = textMessage.getText();
| System.out.println("PartTwoMDB: onMessage: Completed String xml = textMessage.getText();");
|
| System.out.println("PartTwoMDB: onMessage: Begining DistributedObject distributedObject = (DistributedObject)xstream.fromXML(xml);");
| DistributedObject distributedObject = (DistributedObject)xstream.fromXML(xml);
| System.out.println("PartTwoMDB: onMessage: Completed DistributedObject distributedObject = (DistributedObject)xstream.fromXML(xml);");
| System.out.println("PartTwoMDB: onMessage: distributedObject: "+ distributedObject.processID);
|
|
|
| System.out.println("PartTwoMDB: onMessage: Begining JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();");
| JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
| System.out.println("PartTwoMDB: onMessage: Completed JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();");
| try
| {
|
|
| System.out.println("PartTwoMDB: onMessage: Begining ProcessInstance processInstance = jbpmContext.newProcessInstance('processTwo');");
| ProcessInstance processInstance = jbpmContext.newProcessInstance("processTwo");
| System.out.println("PartTwoMDB: onMessage: Completed ProcessInstance processInstance = jbpmContext.newProcessInstance('processTwo');");
|
| System.out.println("PartTwoMDB: onMessage: Current Node " + processInstance.getRootToken().getNode());
| System.out.println("PartTwoMDB: onMessage: Current running process " + processInstance.getId());
|
| System.out.println("PartTwoMDB: onMessage: Begining ContextInstance contextInstance = (ContextInstance) processInstance.getInstance(ContextInstance.class);");
| ContextInstance contextInstance = (ContextInstance) processInstance.getInstance(ContextInstance.class);
| System.out.println("PartTwoMDB: onMessage: Completed ContextInstance contextInstance = (ContextInstance) processInstance.getInstance(ContextInstance.class);");
|
| distributedProcessInstanceID = distributedObject.processID;
|
| System.out.println("PartTwoMDB: onMessage: Begining contextInstance.setVariable('distributedProcessID', distributedProcessInstanceID);");
| contextInstance.setVariable("distributedProcessID", distributedProcessInstanceID);
| System.out.println("PartTwoMDB: onMessage: Completed contextInstance.setVariable('distributedProcessID', distributedProcessInstanceID);");
|
| System.out.println("PartTwoMDB: onMessage: Begining contextInstance.setVariable('bandName', 'The Shockers');");
| contextInstance.setVariable("bandName", "The Shockers");
| System.out.println("PartTwoMDB: onMessage: Completed contextInstance.setVariable('bandName', 'The Shockers');");
|
| System.out.println("PartTwoMDB: onMessage: Begining Token token = processInstance.getRootToken();");
| Token token = processInstance.getRootToken();
| System.out.println("PartTwoMDB: onMessage: Completed Token token = processInstance.getRootToken();");
|
| System.out.println("PartTwoMDB: onMessage: Begining token.signal();");
| token.signal();
| System.out.println("PartTwoMDB: onMessage: Completed token.signal();");
|
| System.out.println("PartTwoMDB: onMessage: Current Node " + processInstance.getRootToken().getNode());
|
|
|
|
| }
| finally
| {
| System.out.println("PartTwoMDB: onMessage(): Begining jbpmContext.close();");
| jbpmContext.close();
| System.out.println("PartTwoMDB: onMessage(): Completed jbpmContext.close();");
| System.out.println("*******************PartTwoMDB - COMPLETED *************************");
| }
|
| }
| else
| {
| System.out.println("PartTwoMDB: onMessage(): Message of wrong type: " + inMessage.getClass().getName());
| }
| }
| catch (Throwable t)
| {
| System.out.println("PartTwoMDB: Throwable cought");
| t.printStackTrace();
| }
|
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4135368#4135368
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4135368
18 years, 1 month
[JBoss jBPM] - Movo to node
by jagr
I've defined a process like this.
| <?xml version="1.0" encoding="UTF-8"?>
| <process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="reserva">
| <swimlane name="reception">
| <assignment actor-id="pepeito"></assignment>
| </swimlane>
| <start-state name="Offer petition">
| <task name="Offer petition" swimlane="reception">
| <controller></controller>
| </task>
| <transition to="searchClient" name="search"></transition>
| </start-state>
| <task-node name="Create client">
| <task name="Create client" swimlane="reception">
| <controller></controller>
| </task>
| <event type="node-enter">
| <action class="com.aixtelecom.actions.CreateClientAction"></action>
| </event>
| <transition to="Create offer" name="crear oferta"></transition>
| </task-node>
| <task-node name="Create offer">
| <task name="Create offer" swimlane="reception">
| <controller></controller>
| </task>
| <event type="node-enter">
| <action class="com.aixtelecom.actions.CreateOfferAction"></action>
| </event>
| <transition to="Createbooking" name="yes"></transition>
| <transition to="finish" name="no"></transition>
| </task-node>
| <task-node name="Createbooking">
| <task name="Createbooking" swimlane="reception">
| <controller></controller>
| </task>
| <transition to="finish" name="Fi"></transition>
| </task-node>
| <node name="searchClient">
| <event type="node-enter">
| <action class="com.aixtelecom.actions.SearchClientAction"></action>
| </event>
| <transition to="Create offer" name="tr_create_offer"></transition>
| <transition to="Create client" name="tr_create_client"></transition>
| </node>
| <end-state name="finish"></end-state>
| </process-definition>
|
At seachClient node i've created action handler on node-enter.
This action is:
| public class SearchClientAction implements ActionHandler{
|
| /** The log. */
| private Logger log = Logger.getLogger(SearchClientAction.class);
|
| private static final long serialVersionUID = 3364679100134686576L;
|
| public void execute(ExecutionContext context) throws Exception {
|
| [connection with external mysql data base]
|
| if (result of query){
| //go to create offer
| node.leave(context, "tr_create_offer");
| }
| else{
| //go to create client
| node.leave(context, "tr_create_client");
| }
| }
| }
|
I want depending on result of query, automatically process go to create client or create offer.
On create client node and create offer node i've configured actions with
System.out.println("Running on CreateClientAction...");
or
System.out.println("### Running on CreateOfferAction");
When i start the process and enter on searchClient node, always the process finish into create offer node.
| 17:06:49,000 INFO [STDOUT] Running on CreateClientAction...
| 17:06:49,000 WARN [ProxyWarnLog] Narrowing proxy to class org.jbpm.graph.node.TaskNode - thi
| s operation breaks ==
| 17:06:49,000 INFO [STDOUT] ### Running on CreateOfferAction
|
Any idea?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4135364#4135364
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4135364
18 years, 1 month