Announcement Announcement Module
Collapse

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions (http://www.springsource.org/extensions) project, this forum has been decommissioned in favour of Spring Extensions one at:
http://forum.springsource.org/forumdisplay.php?f=44

Please see the Spring Extensions home page for a complete list of current projects in Java, .NET and ActionScript. You can also propose one if you want.

Cheers,
Costin Leau
SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
http://twitter.com/costinl
See more
See less
Spring Modules 08a + Jbpm 3.2.6 "Session is closed" hibernate exception. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Modules 08a + Jbpm 3.2.6 "Session is closed" hibernate exception.

    Hi all,

    I am having a hard time configuring the spring-modules jbpmTemplate. I am using Spring ver. 2.5.6.

    When I execute the following code:

    Code:
    jbpmTemplate.execute(new JbpmCallback() {	    	    
                public Object doInJbpm(JbpmContext context) {
                GraphSession gSession = context.getGraphSession();
                gSession.saveProcessDefinition(jbpmTemplate.getProcessDefinition());
              ...
                 ProcessInstance processInstance = context.newProcessInstanceForUpdate("x");
                     ContextInstance contextInstance = processInstance.getContextInstance();
                     ...	
                     context.save(processInstance);
                     
                    ...
                     return null; // I get the error after this line is executed 
                }
            });
    I get :

    Code:
    org.hibernate.SessionException: Session is closed!
    	at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:72)
    	at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:558)
    	at org.hibernate.impl.SessionImpl.save(SessionImpl.java:550)
    	at org.hibernate.impl.SessionImpl.save(SessionImpl.java:546)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:592)
    	at org.springframework.orm.hibernate3.HibernateTemplate$CloseSuppressingInvocationHandler.invoke(HibernateTemplate.java:1293)
    	at $Proxy99.save(Unknown Source)
    	at org.jbpm.svc.save.HibernateSaveOperation.save(HibernateSaveOperation.java:38)
    	at org.jbpm.svc.Services.save(Services.java:173)
    	at org.jbpm.JbpmContext.save(JbpmContext.java:461)
    	at org.jbpm.JbpmContext.autoSave(JbpmContext.java:691)
    	at org.jbpm.JbpmContext.close(JbpmContext.java:129)
    	at org.springmodules.workflow.jbpm31.JbpmTemplate.releaseContext(JbpmTemplate.java:110)
    	at org.springmodules.workflow.jbpm31.JbpmTemplate.execute(JbpmTemplate.java:99)
    	at com.curo.webapp.action.ManagerSubmitAction.submit(ManagerSubmitAction.java:139)
    my jbpm.cfg.xml contains:

    Code:
    <jbpm-configuration>
    
      <jbpm-context>
       
       <service name="persistence">
          <factory>
            <bean class="org.jbpm.persistence.db.DbPersistenceServiceFactory">
                <field name="isTransactionEnabled"><false /></field>
            </bean>
          </factory>
        </service>
       
       <service name="tx" factory="org.jbpm.tx.TxServiceFactory"/>
      	
      
      </jbpm-context>
    and my application context contains:

    Code:
    <bean id="jbpmSessionFactory"
    		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" autowire-candidate="false" name="jbpmSessionFactory">
    		
    		<property name="dataSource" ref="jbpmDataSource" />
    		<property name="configLocation" value="classpath:hibernate.jbpm.cfg.xml" />
    		
    .... 
    
    <bean id="jbpmDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
            <property name="driverClassName" value="${jdbc.driverClassName}"/>
            <property name="url" value="${jdbc.jbpm.url}"/>
    	</bean>
    
    ...
    
     <bean id="processDefinition"
              class="org.springmodules.workflow.jbpm31.definition.ProcessDefinitionFactoryBean">
              <property name="definitionLocation" value="classpath:processdefinition.xml"></property>
        </bean>
    
    	<bean id="jbpmConfiguration"
    		class="org.springmodules.workflow.jbpm31.LocalJbpmConfigurationFactoryBean">
    		  <property name="sessionFactory" ref="jbpmSessionFactory"></property> 
    		  <property name="configuration" value="classpath:jbpm.cfg.xml" />
    		  <property name="createSchema" value="false" />
    		  <property name="processDefinitions">
                   <list>
                        <ref local="processDefinition"></ref>  
                   </list>
              </property>
              <property name="processDefinitionsResources">
         		  <list>
          			  <value>classpath:reportee.processdefinition.xml</value>
         		  </list>
       		  </property>
              
    	</bean>
    
    	<bean id="jbpmTemplate" class="org.springmodules.workflow.jbpm31.JbpmTemplate" > 
    		<constructor-arg index="0" ref="jbpmConfiguration" />	
    		<constructor-arg index="1" ref="processDefinition"/>
    	</bean>  
    	
            ...
    I guess both spring module and jbpm context are trying to close the session. Would you please help me to understand why am I getting this error?
    Last edited by eren.aykin; Mar 17th, 2010, 12:16 PM.

  • #2
    Hi again,

    I solved the problem by adding

    Code:
    context.setSession(jbpmTemplate.getHibernateTemplate().getSessionFactory().openSession());
    to the beginning of the code. The reason of the error I was getting seemed like there were no current sessions, when the template tried to close the session.

    Comment

    Working...
    X