1 Reply Latest reply on Aug 28, 2014 1:55 AM by Maciej Swiderski

    startProcess method gets stuck when using PER_PROCESS_INSTANCE strategy

    Abhishek S Newbie

      Hi All,

       

      Please help me to solve the following problem. I am using JBPM 6.1.0.Final with Spring 3.1.1.RELEASE. I want to use the PER_PROCESS_INSTANCE strategy so that I can  dispose the ksession object as soon as it completes the startProcess or fireAllRules tasks. The major problem is, for this particular strategy, when starting a process using startProcess method the system throws the following exception

       

      ERROR: Cannot insert the value NULL into column 'mappingId', table 'JPA_TEST.dbo.ContextMappingInfo'; column does not allow nulls. INSERT fails.

      javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: Cannot insert the value NULL into column 'mappingId', table 'JPA_TEST.dbo.ContextMappingInfo'; column does not allow nulls. INSERT fails.

          at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1360)

          at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1288)

          at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1294)

          at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:860)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

          at java.lang.reflect.Method.invoke(Unknown Source)

          at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)

          at com.sun.proxy.$Proxy38.persist(Unknown Source)

          at org.jbpm.runtime.manager.impl.mapper.JPAMapper.saveMapping(JPAMapper.java:59)

          at org.jbpm.runtime.manager.impl.PerProcessInstanceRuntimeManager$MaintainMappingListener.beforeProcessStarted(PerProcessInstanceRuntimeManager.java:215)

          at org.drools.core.event.ProcessEventSupport.fireBeforeProcessStarted(ProcessEventSupport.java:40)

          at org.jbpm.process.instance.ProcessRuntimeImpl.startProcessInstance(ProcessRuntimeImpl.java:186)

          at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:169)

          at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:161)

       

      To sort out this issue, I had to mark the mappingId column as an identity field in the ContextMappingInfo. After this change, the system stops responding at the following line marked in blue:

       

           RuntimeEngine runtimeEngine = runtimeManager.getRuntimeEngine(ProcessInstanceIdContext.get());

          KieSession ksession = runtimeEngine.getKieSession();

       

         Map<String, Object> params = new HashMap<String, Object>();
         params.put("money", amount);

       

         ProcessInstance processInstance = ksession.startProcess("com.sample.bpmn",params);

       

      I have attached the configuration files pertaining to the test program.

       

      Kindly help.