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 jBPM Transactions Not Flushing Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring jBPM Transactions Not Flushing

    Hi all,

    I have been working with the new jBPM code in the spring-modules CVS, but none of the calls are being persisted to the database. I have the following spring config, but it seems the JbpmSessionFactoryUtils class cannot get a handle on a Transaction via the TransactionSynchronizationManager. Whenever I instantiate a Hibernate Transaction directly, I have no problems. Also, I am able read data from the database, just not write. Any suggestions?

    Thanks,
    Julian

    Code:
        <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName" value="org.postgresql.Driver"/>
            <property name="url" value="jdbc&#58;postgresql&#58;//localhost&#58;5432/jbpm/>
            <property name="username" value="sa"/>
            <property name="password" value=""/>
        </bean>
    
        <bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
            <property name="dataSource">
                <ref bean="dataSource"/>
            </property>
            <property name="mappingLocations">
                <value>classpath*&#58;/org/jbpm/**/*.hbm.xml</value>
            </property>
            <property name="hibernateProperties">
                <props>
                    <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
                    <prop key="hibernate.show_sql">true</prop>
                </props>
            </property>
            <property name="schemaUpdate" value="true"/>
        </bean>
    
        <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
            <property name="sessionFactory" ref="hibernateSessionFactory"/>
        </bean>
    
        <bean id="hibernateConfiguration" factory-bean="&amp;hibernateSessionFactory" factory-method="getConfiguration"/>
    
        <bean id="jbpmSessionFactory" class="org.springframework.workflow.jbpm.LocalJbpmSessionFactoryBean">
            <property name="hibernateSessionFactory" ref="hibernateSessionFactory"/>
            <property name="hibernateConfiguration" ref="hibernateConfiguration"/>
        </bean>
        
        <bean id="jbpmTemplate" class="org.springframework.workflow.jbpm.JbpmTemplate">
            <property name="jbpmSessionFactory" ref="jbpmSessionFactory"/>
        </bean>

  • #2
    Julian,

    I throughly tested the spring-jbpm module. Rob Harrop told me its still a work in progress, but everything including transaction management is working quite well for me. I've tested JbpmTemplate transaciton intermingled with my domain specific HibernateTemplate transactions. Commits and rollbacks for all participating in the transaction are applied as you would expect.

    I'm using hypersonic right now, looks like you're using postgres.

    I'd like to see your implementation class, here's one I'm using to test writing a ProcessDefinition then retrieving a ProcessInstance

    Code:
    public class SimpleProcessPAOImpl implements SimpleProcessPAO &#123;
        
        private JbpmTemplate jbpmTemplate;
    
        public ProcessDefinition createProcessDef&#40;String xmlFileResource, final String processName&#41; &#123;
            final ProcessDefinition myDefinition = ProcessDefinition.parseXmlResource&#40;xmlFileResource&#41;;
            myDefinition.setName&#40;processName&#41;;
            ProcessDefinition processDef = &#40;ProcessDefinition&#41;jbpmTemplate.execute&#40;new JbpmCallback&#40;&#41;&#123;
                
                public Object doInJbpm&#40;JbpmSession jbpmSession&#41; throws Exception &#123;
                    GraphSession gSession = jbpmSession.getGraphSession&#40;&#41;;
                    gSession.saveProcessDefinition&#40;myDefinition&#41;;
                    return myDefinition;
                &#125;&#125;&#41;;
    
            return processDef;
        &#125;
        
        public void setJbpmSessionFactory&#40;JbpmSessionFactory jbpmSessionFactory&#41;
        &#123;
            jbpmTemplate = new JbpmTemplate&#40;jbpmSessionFactory&#41;;
        &#125;
    
        public ProcessInstance findProcessInstance&#40;Long processId&#41; &#123;
            return jbpmTemplate.findProcessInstance&#40;processId&#41;;
        &#125;
    
        public ProcessInstance createNewProcessInstance&#40;ProcessDefinition def&#41; &#123;
            ProcessInstance resultInstance = new ProcessInstance&#40;def&#41;;
            long instanceId = jbpmTemplate.saveProcessInstance&#40;resultInstance&#41;;
            return resultInstance;
            
        &#125;
        
        
    
    &#125;
    I'm calling this code inside of a transaction kicked of by the AbstractTransactionalDataSourceSpringContextTests class from spring-mock. In another case, to really see the transaction boundaries, I'm calling this code inside of a TransactionTemplate.execute().

    Comment

    Working...
    X