<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
session closed
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/AJanz">Sascha Janz</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/594254#594254">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>i am using seam 2.2 with jbpm.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>when executing several jbpm command like signal or saveprocessinstance i got an exception "session closed"</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>if i execute them via command service bean from jbpm-enterprise.ear everything is ok. where is the difference?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>here are my configurations.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>jbpm </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><jbpm-configuration></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  <jbpm-context></p><p>    <service name="persistence" factory="org.jbpm.persistence.jta.JtaDbPersistenceServiceFactory" /></p><p>    <service name="tx" factory="org.jbpm.tx.TxServiceFactory" /></p><p>    <service name="message" factory="org.jbpm.msg.db.DbMessageServiceFactory" /></p><p>    <service name="scheduler" factory="org.jbpm.scheduler.db.DbSchedulerServiceFactory" /></p><p>    <service name="logging" factory="org.jbpm.logging.db.DbLoggingServiceFactory" /></p><p>    <service name="authentication" factory="org.jbpm.security.authentication.DefaultAuthenticationServiceFactory" /></p><p>  </jbpm-context></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p></jbpm-configuration></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>hibernate </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><?xml version="1.0" encoding="UTF-8"?></p><p><!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"</p><p><span>                                         "</span><a class="jive-link-external-small" href="http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd" target="_blank">http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd</a><span>"></span></p><p><hibernate-configuration></p><p><session-factory></p><p>  <!-- hibernate dialect --></p><p>  <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property></p><p>  <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property></p><p>  <!-- DataSource properties (begin) </p><p>property name="hibernate.connection.datasource">java:comp/env/jdbc/JbpmDataSource</property</p><p>DataSource properties (end) </p><p>DataSource properties (begin) === --></p><p>  <property name="hibernate.connection.datasource">java:/JbpmDS</property></p><p>  <!-- ==== DataSource properties (end) </p><p>JTA transaction properties (begin) --></p><p>  <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property></p><p>  <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property></p><p>  <property name="jta.UserTransaction">java:comp/UserTransaction</property></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>     <!-- JTA transaction properties (end) </p><p>..</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>an my commmand bean </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>import java.sql.Connection;</p><p>import java.sql.SQLException;</p><p>import java.util.List;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>import javax.ejb.Remove;</p><p>import javax.ejb.Stateful;</p><p>import javax.ejb.TransactionAttribute;</p><p>import javax.ejb.TransactionAttributeType;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>import org.apache.log4j.Logger;</p><p>import org.jboss.seam.annotations.AutoCreate;</p><p>import org.jboss.seam.annotations.Name;</p><p>import org.jbpm.JbpmConfiguration;</p><p>import org.jbpm.JbpmContext;</p><p>import org.jbpm.command.Command;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>import de.lorenz.soaworkflow.core.performanceprofile.Profiler;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>@Name("CommandService")</p><p>@Stateful</p><p>@AutoCreate</p><p>public class CommandServiceBean implements CommandService{</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>private static final Logger log = Logger.getLogger(CommandServiceBean.class</p><p>   .getName());</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>static JbpmConfiguration cfg = JbpmConfiguration</p><p>   .parseResource("resources/jbpm.cfg.xml");</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>// AJ 22.1.2010</p><p>// default ist jetzt ohne CommandServiceBean</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)</p><p>public Object executeCommand(Command cmd) {</p><p>  Object returnValue = null;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  log.debug("Begin execute command ");</p><p>  long start = 0;</p><p>  if (Profiler.isProfiling())</p><p>   start = Profiler.startProfile("CommandBean:executeCommand");</p><p>  JbpmContext jbpmContext = null;</p><p>  Connection con = null;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  try {</p><p>   // AJ 11.2.2010 muss jedesmal neu erzeugt werden!!!</p><p>   // da n Threads hierauf zugreifen!</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>   jbpmContext = cfg.createJbpmContext();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>   // con = ConnectionManager.getInstance().getConnection();</p><p>   // jbpmContext.setConnection(con);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>   if (jbpmContext == null)</p><p>    throw new Exception("Error now jbpm context!");</p><p>   returnValue = cmd.execute(jbpmContext);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  } catch (Exception e) {</p><p>   log.error("Error executeCommand", e);</p><p>  } finally {</p><p>   if (jbpmContext != null) {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    jbpmContext.close();</p><p>    jbpmContext = null;</p><p>    try {</p><p>     if (con != null) {</p><p>      con.close();</p><p>     }</p><p>    } catch (SQLException e) {</p><p>     // TODO Auto-generated catch block</p><p>     e.printStackTrace();</p><p>    }</p><p>   }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  log.debug("End execute command ");</p><p>  if (Profiler.isProfiling())</p><p>   Profiler.endProfile("CommandBean:executeCommand", start);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  return returnValue;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>}</p><p>     @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)</p><p>public Object executeCommands(List<Command> cmdlist) {</p><p>  Object returnValue = null;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  log.debug("Begin executeCommands ");</p><p>  long start = 0;</p><p>  if (Profiler.isProfiling())</p><p>   start = Profiler.startProfile("CommandBean:executeCommands");</p><p>  JbpmContext jbpmContext = null;</p><p>  Connection con = null;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  try {</p><p>   // AJ 11.2.2010 muss jedesmal neu erzeugt werden!!!</p><p>   // da n Threads hierauf zugreifen!</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>   jbpmContext = cfg.createJbpmContext();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>   // con = ConnectionManager.getInstance().getConnection();</p><p>   // jbpmContext.setConnection(con);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>   if (jbpmContext == null)</p><p>    throw new Exception("Error now jbpm context!");</p><p>   for ( Command cmd : cmdlist ) { </p><p>    System.out.println("execute " + cmd.getClass().getName());</p><p>   returnValue = cmd.execute(jbpmContext);</p><p>   }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  } catch (Exception e) {</p><p>   log.error("Error CommandBean:executeCommands", e);</p><p>      } finally {</p><p>   if (jbpmContext != null) {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    jbpmContext.close();</p><p>    jbpmContext = null;</p><p>    try {</p><p>     if (con != null) {</p><p>      con.close();</p><p>     }</p><p>    } catch (SQLException e) {</p><p>     // TODO Auto-generated catch block</p><p>     e.printStackTrace();</p><p>    }</p><p>   }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  log.debug("End CommandBean:executeCommands");</p><p>  if (Profiler.isProfiling())</p><p>   Profiler.endProfile("CommandBean:executeCommands", start);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  return returnValue;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>   @Remove</p><p>public void remove () {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  System.out.println("remove command service ");</p><p>    }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>stacktrace </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>SignalCommand</p><p>17:39:58,804 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TwoPhaseC</p><p>ordinator_2] TwoPhaseCoordinator.beforeCompletion - failed for com.arjuna.ats.i</p><p>ternal.jta.resources.arjunacore.SynchronizationImple@1ee32dd</p><p>org.hibernate.SessionException: Session is closed!</p><p>        at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSession</p><p>mpl.java:49)</p><p>        at org.hibernate.impl.SessionImpl.getNamedQuery(SessionImpl.java:1258)</p><p>        at org.jbpm.db.JobSession$DeleteJobsSynchronization.beforeCompletion(Jo</p><p>Session.java:190)</p><p>        at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImpl</p><p>.beforeCompletion(SynchronizationImple.java:114)</p><p>        at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompleti</p><p>n(TwoPhaseCoordinator.java:247)</p><p>        at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCo</p><p>rdinator.java:86)</p><p>        at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)</p><p>        at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.</p><p>ommitAndDisassociate(TransactionImple.java:1389)</p><p>        at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.c</p><p>mmit(BaseTransaction.java:135)</p><p>        at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTr</p><p>nsactionManagerDelegate.java:87)</p><p>        at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:175)</p><p>        at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)</p><p>        at org.jboss.aspects.tx.TxInterceptor$RequiresNew.invoke(TxInterceptor.</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/594254#594254">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>