1 2 3 Previous Next 35 Replies Latest reply on Dec 5, 2009 5:36 AM by saraswati.santanu Go to original post
      • 30. Re: Problem moving from 4.1 to 4.2 using Spring configuratio
        suganda

        Hi saraswati.santanu,

        I have tried to using JBPM 4.2 With Spring configuration. However, I have weird exception when enable current="true"

        <hibernate-session current="true"/>

        if i am using

        <hibernate-session />
        <hibernate-session current="true"/>

        or

        <hibernate-session />

        I can successfully insert record, or reading from database. However if I set current="true" I will get exception


        <?xml version="1.0" encoding="UTF-8"?>
        
        <jbpm-configuration xmlns="http://jbpm.org/xsd/cfg">
        
         <process-engine-context>
        
         <repository-service />
         <repository-cache />
         <execution-service />
         <history-service />
         <management-service />
         <task-service />
         <identity-service />
         <!--<transaction />-->
        
         <!--<command-service>
         <retry-interceptor />
         <environment-interceptor />
         <spring-transaction-interceptor current="true"/>
         </command-service>-->
        
         <command-service name="txRequiredCommandService">
         <retry-interceptor />
         <environment-interceptor transactionManager="dxf.hbTxManager"/>
         <spring-transaction-interceptor />
         </command-service>
        
         <!--<command-service name="newTxRequiredCommandService">
         <retry-interceptor />
         <environment-interceptor policy="requiresNew" />
         <spring-transaction-interceptor />
         </command-service>-->
        
         <deployer-manager>
         <jpdl-deployer />
         </deployer-manager>
        
         <object class="org.jbpm.pvm.internal.id.DatabaseDbidGenerator">
         <field name="commandService"><ref object="txRequiredCommandService" /></field>
         <!--<field name="commandService"><ref object="newTxRequiredCommandService" /></field>-->
         </object>
        
         <object class="org.jbpm.pvm.internal.id.DatabaseIdComposer" init="eager" />
        
         <script-manager default-expression-language="juel"
         default-script-language="juel"
         read-contexts="execution, environment,
         process-engine, spring"
         write-context="">
         <script-language name="juel" factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />
         </script-manager>
        
         <authentication />
        
         <job-executor auto-start="false" />
        
         <id-generator />
         <types resource="jbpm.variable.types.xml" />
        
         <business-calendar>
         <monday hours="9:00-12:00 and 12:30-17:00"/>
         <tuesday hours="9:00-12:00 and 12:30-17:00"/>
         <wednesday hours="9:00-12:00 and 12:30-17:00"/>
         <thursday hours="9:00-12:00 and 12:30-17:00"/>
         <friday hours="9:00-12:00 and 12:30-17:00"/>
         <holiday period="01/07/2008 - 31/08/2008"/>
         </business-calendar>
        
         </process-engine-context>
        
         <transaction-context>
         <repository-session />
         <db-session />
         <pvm-db-session />
         <job-db-session />
         <task-db-session />
         <message-session />
         <timer-session />
         <history-session />
         <!--<transaction />-->
         <hibernate-session />
         <hibernate-session current="true"/>
         <identity-session />
         </transaction-context>
        </jbpm-configuration>
        


        Exception Stack Trace
        org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processEngine' defined in URL [file:/C:/Suganda/jbpm-4.2/workspace/dxf-comp/bin/com/gda/dxf/comp/resources/spring/spring-service-jbpm.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.jbpm.api.ProcessEngine org.jbpm.pvm.internal.cfg.SpringConfiguration.buildProcessEngine()] threw exception; nested exception is org.jbpm.api.JbpmException: no jBPM DB schema: no JBPM4_EXECUTION table. Run the create.jbpm.schema target first in the install tool.
        Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'initialFillService' defined in URL [file:/C:/Suganda/jbpm-4.2/workspace/dxf-comp/bin/com/gda/dxf/comp/resources/spring/spring-service.xml]: Cannot resolve reference to bean '_initialFillService' while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_initialFillService' defined in URL [file:/C:/Suganda/jbpm-4.2/workspace/dxf-comp/bin/com/gda/dxf/comp/resources/spring/spring-service-jbpm.xml]: Cannot resolve reference to bean 'repositoryService' while setting bean property 'repositoryService'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'processEngine': Requested bean is currently in creation: Is there an unresolvable circular reference?
        Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'deployService' defined in URL [file:/C:/Suganda/jbpm-4.2/workspace/dxf-comp/bin/com/gda/dxf/comp/resources/spring/spring-service.xml]: Cannot resolve reference to bean '_deployService' while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_deployService' defined in URL [file:/C:/Suganda/jbpm-4.2/workspace/dxf-comp/bin/com/gda/dxf/comp/resources/spring/spring-service-jbpm.xml]: Cannot resolve reference to bean 'repositoryService' while setting bean property 'repositoryService'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'processEngine': Requested bean is currently in creation: Is there an unresolvable circular reference?
         at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:551)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:964)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:868)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
         at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:289)
         at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
         at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:286)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:188)
         at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:558)
         at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:852)
         at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:422)
         at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
         at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
        


        Please Help me as I already check many forums but they always recommended using current="true"

        I also dont use current="true" in <spring-transaction-interceptor /> in which I will get exception if i enable true of it. However the documentation stated we should enable both of them to true. I am confuse whether JBPM Documentation is wrong or I have wrong setting that cause me that exception.

        Thanks in advance,

        Best Regards,
        Suganda

        • 31. Re: Problem moving from 4.1 to 4.2 using Spring configuratio
          saraswati.santanu

          Suganda,
          It will be helpful if you can upload a sample jpdl you want to execute and a small code snippet that can deploy and start that flow.

          It is difficult to conclude anything by looking at the stack trace. But the root of the exception suggests some missing tables.

          Factory method [public org.jbpm.api.ProcessEngine org.jbpm
          .pvm.internal.cfg.SpringConfiguration.buildProcessEngine()] threw exception; nested exception is org
          .jbpm.api.JbpmException: no jBPM DB schema: no JBPM4_EXECUTION table. Run the create.jbpm.schema t
          arget first in the install tool.
          

          So make sure that the schema for JBPM is created properly.

          As for spring-transaction-interceptor, I would say it is okay to use current=false. In fact I prefer not to set current=true. current=true expects a transaction to be present, while as current=false creates a transaction if it does not exists, and uses the existing one if already exists. In short current=true means propagation behaviour MANDATORY and current=false means propagation behaviour REQUIRED.

          • 32. Re: Problem moving from 4.1 to 4.2 using Spring configuratio
            suganda

            Hi Saraswati,

            Thanks for the reply

            Below is complete snippet for this weird exception

            Spring Configuration

            <?xml version="1.0" encoding="UTF-8"?>
            <beans xmlns="http://www.springframework.org/schema/beans"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:aop="http://www.springframework.org/schema/aop"
             xmlns:tx="http://www.springframework.org/schema/tx"
             xsi:schemaLocation="
             http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
             http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
             http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
            
             <bean id="dol.jdbcDatasource"
             class="org.springframework.jdbc.datasource.DriverManagerDataSource" lazy-init="true" >
             <property name="driverClassName" value="com.mysql.jdbc.Driver" />
             <property name="url" value="jdbc:mysql://${dol.jdbc.server}:${dol.jdbc.port}/${dol.jdbc.database}" />
             <property name="username" value="${dol.jdbc.loginuser}" />
             <property name="password" value="${dol.jdbc.password}" />
             </bean>
            
             <bean id="dol.hbSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
             <property name="dataSource"> <ref bean="${dol.datasource}"/> </property>
             <property name="mappingLocations">
             <list>
             <value>classpath:com/gda/dol/comp/resources/hibernate/jbpm.repository.hbm.xml</value>
             <value>classpath:com/gda/dol/comp/resources/hibernate/jbpm.execution.hbm.xml</value>
             <value>classpath:com/gda/dol/comp/resources/hibernate/jbpm.history.hbm.xml</value>
             <value>classpath:com/gda/dol/comp/resources/hibernate/jbpm.task.hbm.xml</value>
             <value>classpath:com/gda/dol/comp/resources/hibernate/jbpm.identity.hbm.xml</value>
             </list>
             </property>
             <property name="schemaUpdate" value="false"/>
             <property name="hibernateProperties">
             <props>
             <prop key="hibernate.show_sql">true</prop>
             <prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</prop>
             <prop key="hibernate.jdbc.batch_size">50</prop>
             <prop key="hibernate.cache.use_second_level_cache">false</prop>
             <prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</prop>
             <prop key="hibernate.cache.provider_class">org.hibernate.cache.OSCacheProvider</prop>
             <prop key="hibernate.current_session_context_class">thread</prop>
             <prop key="hibernate.connection.release_mode">after_transaction</prop>
             </props>
             </property>
             <property name="configLocations">
             <list>
             <value>classpath:com/gda/dol/comp/resources/jbpm/hibernate.cfg.xml</value>
             </list>
             </property>
             </bean>
            
             <bean id="dol.hbTxManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" lazy-init="true">
             <property name="sessionFactory" ref="dol.hbSessionFactory"/>
             </bean>
            
             <bean id="jbpmConfiguration" class="org.jbpm.pvm.internal.cfg.SpringConfiguration">
             <constructor-arg value="com/gda/dol/comp/resources/jbpm/jbpm.cfg.xml" />
             </bean>
            
             <bean id="processEngine" factory-bean="jbpmConfiguration" factory-method="buildProcessEngine" />
             <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
             <bean id="executionService" factory-bean="processEngine" factory-method="getExecutionService" />
             <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
            
             <bean id="_deployService" class="com.gda.dol.comp.jbpm.impl.DeployServiceImpl">
             <property name="repositoryService" ref="repositoryService" />
             </bean>
            
             <bean id="processInformationService"
             class="com.gda.dol.comp.jbpm.impl.ProcessInformationServiceImpl">
             <property name="repositoryService" ref="repositoryService" />
             <property name="executionService" ref="executionService" />
             </bean>
            
             <bean id="simpleProcessService"
             class="com.gda.dol.comp.jbpm.impl.SimpleProcessServiceImpl">
             <property name="repositoryService" ref="repositoryService" />
             <property name="executionService" ref="executionService" />
             </bean>
            
             <bean id="_echoService" class="com.gda.dol.comp.jbpm.impl.EchoServiceImpl" />
            
             <bean id="_initialFillService" class="com.gda.dol.comp.jbpm.impl.InitialFillServiceImpl">
             <property name="repositoryService" ref="repositoryService" />
             </bean>
            
             <bean id="abstractService"
             class="com.gda.abc.xxx.framework.springSupport.SpringServiceFactory"
             abstract="true">
             <property name="transactionManager">
             <ref bean="${dol.application.txManager}" />
             </property>
             <property name="transactionAttributes">
             <props>
             <prop key="*">PROPAGATION_REQUIRED,-Exception</prop>
             </props>
             </property>
             </bean>
            
             <bean id="echoService" parent="abstractService">
             <property name="target">
             <ref bean="_echoService" />
             </property>
             <property name="proxyInterfaces">
             <list>
             <value>
             com.gda.dol.comp.jbpm.EchoService
             </value>
             </list>
             </property>
             </bean>
            
             <bean id="initialFillService" parent="abstractService">
             <property name="target">
             <ref bean="_initialFillService" />
             </property>
             <property name="proxyInterfaces">
             <list>
             <value>
             com.gda.dol.comp.jbpm.InitialFillService
             </value>
             </list>
             </property>
             </bean>
            
             <bean id="deployService" parent="abstractService">
             <property name="target">
             <ref bean="_deployService" />
             </property>
             <property name="proxyInterfaces">
             <list>
             <value>
             com.gda.dol.comp.jbpm.DeployService
             </value>
             </list>
             </property>
             </bean>
            </beans>
            


            JBPM Configuration
            <?xml version="1.0" encoding="UTF-8"?>
            
            <jbpm-configuration xmlns="http://jbpm.org/xsd/cfg">
            
             <process-engine-context>
            
             <repository-service />
             <repository-cache />
             <execution-service />
             <history-service />
             <management-service />
             <task-service />
             <identity-service />
            
             <command-service name="txRequiredCommandService">
             <retry-interceptor />
             <environment-interceptor transactionManager="dol.hbTxManager"/>
             <spring-transaction-interceptor />
             </command-service>
            
             <deployer-manager>
             <jpdl-deployer />
             </deployer-manager>
            
             <object class="org.jbpm.pvm.internal.id.DatabaseDbidGenerator">
             <field name="commandService"><ref object="txRequiredCommandService" /></field>
             </object>
            
             <object class="org.jbpm.pvm.internal.id.DatabaseIdComposer" init="eager" />
            
             <script-manager default-expression-language="juel"
             default-script-language="juel"
             read-contexts="execution, environment,
             process-engine, spring"
             write-context="">
             <script-language name="juel" factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />
             </script-manager>
            
             <authentication />
            
             <job-executor auto-start="false" />
            
             <id-generator />
             <types resource="jbpm.variable.types.xml" />
            
             <business-calendar>
             <monday hours="9:00-12:00 and 12:30-17:00"/>
             <tuesday hours="9:00-12:00 and 12:30-17:00"/>
             <wednesday hours="9:00-12:00 and 12:30-17:00"/>
             <thursday hours="9:00-12:00 and 12:30-17:00"/>
             <friday hours="9:00-12:00 and 12:30-17:00"/>
             <holiday period="01/07/2008 - 31/08/2008"/>
             </business-calendar>
            
             </process-engine-context>
            
             <transaction-context>
             <repository-session />
             <db-session />
             <pvm-db-session />
             <job-db-session />
             <task-db-session />
             <message-session />
             <timer-session />
             <history-session />
             <!--<transaction />
             <hibernate-session />-->
             <hibernate-session current="true"/>
             <identity-session />
             </transaction-context>
            </jbpm-configuration>
            


            hibernate.cfg.xml
            <?xml version="1.0" encoding="utf-8"?>
            <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
             "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
            <hibernate-configuration>
             <!--<session-factory name="jbpm4-spring">-->
             <session-factory>
             <property name="hibernate.bytecode.use_reflection_optimizer">false</property>
             </session-factory>
            </hibernate-configuration>


            InitialFillServiceImpl class
            public class InitialFillServiceImpl implements InitialFillService{
             private RepositoryService repositoryService;
            
             public void testGanda(){
             /*NewDeployment newDeployment = repositoryService.createDeployment();
             newDeployment.setName("TestSpring");
             newDeployment.setTimestamp(new Date().getTime());
             newDeployment.addResourceFromClasspath("com/gda/dol/comp/jbpm/impl/process.jpdl.xml");
             newDeployment.deploy();*/
             List<Deployment> deploymentIdList = repositoryService.createDeploymentQuery().list();
             for(Deployment deployment : deploymentIdList){
             int i = 1;
             System.out.println("Retrieve element : "+i);
             System.out.println("Deployment ID : "+deployment.getId());
             System.out.println("Deployment Name : "+deployment.getName());
             i++;
             }
             }
            
             public void setRepositoryService(RepositoryService repositoryService) {
             this.repositoryService = repositoryService;
             }
            
            }
            


            process.jpdl.xml
            <?xml version="1.0" encoding="UTF-8"?>
            
            <process name="EndState" xmlns="http://jbpm.org/4.2/jpdl">
            
             <start g="16,96,48,48">
             <transition to="get return code"/>
             </start>
            
             <state name="get return code" g="96,94,110,52">
             <transition name="200" to="ok" g="150,63:-36,11"/>
             <transition name="400" to="bad request" g=":-16,-27"/>
             <transition name="500" to="internal server error" g="150,177:-33,-32"/>
             </state>
            
             <end name="ok" state="completed" g="239,40,48,48"/>
             <end-cancel name="bad request" g="239,97,48,48"/>
             <end-error name="internal server error" g="240,154,48,48"/>
            
            </process>


            Same Exception that i have posted earlier.

            Yup, I noticed if i make it current="true" for <spring-transaction-interceptor />, I will get another exception something like Mandatory Exception. Thatys why I enable it, and can run with it.

            I already double check the table schema, and i have that JBPM4_EXECUTION table because previously i run the script in install directory.

            The Weird things is located in this 3 lines in jbpm.cfg.xml
            <!--
            <hibernate-session />-->
            <hibernate-session current="true"/>

            if I make current="false" in hibernate-session , I can run my program without any error, I can deploy as well as retrieve information's from JBPM Tables, However the problem ONLY occurs when i set current="true" in hibernate-session which is recommended by everyone including mandatory by JBPM Documentation. I am not sure why this happened ?

            any clue ?

            Thanks in advance,

            Best Regards,
            Suganda



            • 33. Re: Problem moving from 4.1 to 4.2 using Spring configuratio
              suganda

              Hi Saraswati,

              Just now I added additional logic of force rollback in my class to know whether it will rollback or not. I found it won't rollback and still successfully deploy my service even thought i force the system to rollback

              Attached is the code of the class

              public class InitialFillServiceImpl implements InitialFillService{
               private RepositoryService repositoryService;
              
               public void testGanda(){
               NewDeployment newDeployment = repositoryService.createDeployment();
               newDeployment.setName("TestSpring");
               newDeployment.setTimestamp(new Date().getTime());
               newDeployment.addResourceFromClasspath("com/gda/dol/comp/jbpm/impl/process.jpdl.xml");
               newDeployment.deploy();
               List<Deployment> deploymentIdList = repositoryService.createDeploymentQuery().list();
               for(Deployment deployment : deploymentIdList){
               int i = 1;
               System.out.println("Retrieve element : "+i);
               System.out.println("Deployment ID : "+deployment.getId());
               System.out.println("Deployment Name : "+deployment.getName());
               i++;
               }
               throw new Exception("xxxx");
               }
              
               public void setRepositoryService(RepositoryService repositoryService) {
               this.repositoryService = repositoryService;
               }
              
              }
              
              


              So, its means JBPM will create or instantiate its own transaction not using Spring transaction since i set current="false" in hibernate sessions ?

              anyone can help to explain this weird scenario ?

              Thanks in advance,

              Best Regards,
              Suganda

              • 34. Re: Problem moving from 4.1 to 4.2 using Spring configuratio
                suganda

                Hi all,

                Just want to share the solution

                After searching and testing , i think i have found the root cause of that weird exception. its because i let hibernate manage my transaction instead of spring. so its better to have spring manage transaction.

                The concept of current="true" in spring transaction interceptor also correct. I already enable current="true" and it works perfectly with current="true" in hibernate session if we let spring manage transaction because if we initialize spring context with required transaction at first time, we always have transaction. So by right mandatory attributes is better then required attributes. So we will make sure every thread has active transaction otherwise it will throw exception.

                Note that if we set current="false" in hibernate session configuration, we still can run it. However if you rollback using spring transaction, it will not rollback. I have tested it by putting exception after deploy process to JBPM. and its not rollback at all.

                I will try whether this behavior same if we use data source (JNDI), JTA, as well as oracle dialect. Hopefully everything don't have same problem :)

                Thanks in advance,

                Best Regards,
                Suganda

                • 35. Re: Problem moving from 4.1 to 4.2 using Spring configuratio
                  saraswati.santanu

                  Thanks for sharing the solution Suganda.

                  You have rightly pointed out that its always good to allow Spring to manage transaction when you use Spring-Hibernate combination. In fact you will not have an option other than this if you are using JMS or any non-db transactional service.

                  I, however, would disagree with you on the spring interceptor current= true option. This is normally OK to have not transaction in a thread to start with. Then somebody (for this case Spring) needs to start the transaction. Ans everybody else should use the existing transaction. If, say from web tier (from a servlet) first call goes to some Jbpm command service call then I would expect that to start the transaction and not to crib about not having a transaction. In such a case current=false makes more sense.

                  But again, with spring you can use OncePerRequestFilter kind of thing to get your transaction started. Such a case you have the option to use current=true.

                  I am sure everything remains same for JTA transaction, so there should be no more pain for you in this.

                  1 2 3 Previous Next