0 Replies Latest reply on Apr 4, 2017 2:10 PM by S D

    JBPM 6: persisting process variable in specific table

    S D Newbie

      I have a simple process embedded in java application. I need to persist one of the process variable in a custom table.

       

      I followed the instructions in jBPM 6 - store your process variables anywhere | Planet JBoss Developer

       

      But while I start the process, it is giving "no transaction in progress@ while persisting that variable all the other information getting persisted ok. It seems it is using a different transaction while persisting my class. I see jdbc connection being fetched while selecting from the DB seq in my class and while doing select during merge(). Please help to solve the issue.

       

      Entity class:

      @Entity

      @Access(AccessType.FIELD)

      @Table(name = "ALGOEXCEPTIONTASK")

      @SequenceGenerator(name = "idGenerator", sequenceName = "SEAM_TASKID_SEQ", allocationSize = 1)

      public class AlgoExceptionTask implements IExceptionTask {

        @Id

        @GeneratedValue(strategy = GenerationType.AUTO, generator = "idGenerator")

        private Long id;

        @Column(name = "TASKID")

        private long taskId;

        @Column(name = "NAME")

        private String name;

       

      //setter and getters, equals and hashcode

      }

       

      Spring file (relevant portion):

        <bean id="jbpmEMF"

          class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">

          <property name="persistenceUnitName" value="org.jbpm.persistence.spring.local" />

          <property name="dataSource" ref="atshistOracleDataSource" />

          <property name="jpaProperties">

            <props>

              <prop key="hibernate.max_fetch_depth">3</prop>

              <prop key="hibernate.show_sql">true</prop>

              <prop key="hibernate.hbm2ddl.auto">update</prop>

              <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>

              <!-- prop key="hibernate.default_schema">test</prop -->

              <prop key="hibernate.id.new_generator_mappings">false</prop>

            </props>

          </property>

          <property name="persistenceXmlLocation" value="classpath:persistence-local.xml" />

        </bean>

       

        <bean id="jbpmEM"

          class="org.springframework.orm.jpa.support.SharedEntityManagerBean">

          <property name="entityManagerFactory" ref="jbpmEMF" />

        </bean>

       

        <tx:annotation-driven transaction-manager="jbpmTxManager"/>

       

        <bean id="jbpmTxManager" class="org.springframework.orm.jpa.JpaTransactionManager">

          <property name="entityManagerFactory" ref="jbpmEMF" />

          <qualifier value="jbpm" />

        </bean>

       

        <bean id="process" factory-method="newClassPathResource"

          class="org.kie.internal.io.ResourceFactory">

          <constructor-arg>

            <value>process/seam/seam.bpmn</value>

          </constructor-arg>

        </bean>

       

        <bean id="runtimeEnvironment"

          class="org.kie.spring.factorybeans.RuntimeEnvironmentFactoryBean">

          <property name="type" value="DEFAULT" />

          <property name="entityManagerFactory" ref="jbpmEMF" />

          <property name="entityManager" ref="jbpmEM" />

          <property name="transactionManager" ref="jbpmTxManager" />

          <property name="userGroupCallback" ref="eesUserGroupCallback" />

          <property name="environmentEntries">

            <map>

              <entry key="org.kie.api.marshalling.ObjectMarshallingStrategies">

                <array value-type="org.kie.api.marshalling.ObjectMarshallingStrategy">

                  <bean

                    class="org.drools.persistence.jpa.marshaller.JPAPlaceholderResolverStrategy">

                    <constructor-arg>

                      <ref bean="jbpmEMF" />

                    </constructor-arg>

                  </bean>

                  <bean

                    class="org.drools.core.marshalling.impl.SerializablePlaceholderResolverStrategy">

                    <constructor-arg>

                      <util:constant

                        static-field="org.drools.core.marshalling.impl.ClassObjectMarshallingStrategyAcceptor.DEFAULT" />

                    </constructor-arg>

                  </bean>

                </array>

              </entry>

            </map>

          </property>

          <property name="assets">

            <map>

              <entry key-ref="process">

                <util:constant static-field="org.kie.api.io.ResourceType.BPMN2" />

              </entry>

            </map>

          </property>

        </bean>

       

        <bean id="runtimeManager" class="org.kie.spring.factorybeans.RuntimeManagerFactoryBean"

          destroy-method="close">

          <property name="identifier" value="spring-rm" />

          <property name="runtimeEnvironment" ref="runtimeEnvironment" />

          <property name="type" value="PER_REQUEST" />

        </bean>

       

      Java Code:

      ObjectMapper mapper = new ObjectMapper();
      mapper.setDateFormat(new SimpleDateFormat("yyyyMMdd"));
      final AlgoExceptionTask exceptionTask = mapper.readValue(task, AlgoExceptionTask.class);
      String versionJson = mapper.writeValueAsString(exceptionTask.getVersionDetails());
      exceptionTask.setVersionDetailsJson(versionJson);
      final User user = ServiceUtil.getUser(request);

         

      Map<String, Object> data = new HashMap<String, Object>() {
        {
          put("Task", exceptionTask);
          //put("User", user);
          put("Role", role);
        }
      };

       

      ProcessInstance p = ksession.startProcess("cotown.lib.workflow.resource.rest.seam", data);
      exceptionTask.setTaskId(p.getId());

       

       

      Exception:

       

      2017-04-04 17:49:01,309 [http-bio-8080-exec-4] DEBUG org.hibernate.SQL  - select algoexcept0_.id as id1_0_0_, algoexcept0_.NUMFAILEDTEST as NUMFAILE2_0_0_, algoexcept0_.NUMFAILEDVERSION as NUMFAILE3_0_0_, algoexcept0_.JPMALINK as JPMALINK4_0_0_, algoexcept0_.NAME as NAME5_0_0_, algoexcept0_.AVGPRICE as AVGPRICE6_0_0_, algoexcept0_.ENDTIME as ENDTIME7_0_0_, algoexcept0_.EXECUTIONNOTIONAL as EXECUTIO8_0_0_, algoexcept0_.EXECUTIONQUANTITY as EXECUTIO9_0_0_, algoexcept0_.INSTRUCTION as INSTRUC10_0_0_, algoexcept0_.LIMITPRICE as LIMITPR11_0_0_, algoexcept0_.ORDERNOTIONAL as ORDERNO12_0_0_, algoexcept0_.ORDERTYPE as ORDERTY13_0_0_, algoexcept0_.ORDERQUAMTITY as ORDERQU14_0_0_, algoexcept0_.STARTTIME as STARTTI15_0_0_, algoexcept0_.ORDERID as ORDERID16_0_0_, algoexcept0_.ADVPERCENTAGE as ADVPERC17_0_0_, algoexcept0_.ESTMKTIMPACT as ESTMKTI18_0_0_, algoexcept0_.ESTSPREADCOST as ESTSPRE19_0_0_, algoexcept0_.ESTTRADINGCOST as ESTTRAD20_0_0_, algoexcept0_.INTERNALMOMENTUM as INTERNA21_0_0_, algoexcept0_.INTERNALSPREAD as INTERNA22_0_0_, algoexcept0_.LIAVOLPERCENTAGE as LIAVOLP23_0_0_, algoexcept0_.MKTVOLUME as MKTVOLU24_0_0_, algoexcept0_.TRADEDURATION as TRADEDU25_0_0_, algoexcept0_.VOLATILITY as VOLATIL26_0_0_, algoexcept0_.ARRIVALMID as ARRIVAL27_0_0_, algoexcept0_.BENCHMARK as BENCHMA28_0_0_, algoexcept0_.CLOSE as CLOSE29_0_0_, algoexcept0_.COSTADJMID as COSTADJ30_0_0_, algoexcept0_.COSTMKTADJMID as COSTMKT31_0_0_, algoexcept0_.LAST as LAST32_0_0_, algoexcept0_.LIAVWAP as LIAVWAP33_0_0_, algoexcept0_.MKTADJMID as MKTADJM34_0_0_, algoexcept0_.OPEN as OPEN35_0_0_, algoexcept0_.PREVCLOSE as PREVCLO36_0_0_, algoexcept0_.TASKID as TASKID37_0_0_, algoexcept0_.VERSIONDETAILS as VERSION38_0_0_ from ALGOEXCEPTIONTASK algoexcept0_ where algoexcept0_.id=?

      2017-04-04 17:49:01,309 [http-bio-8080-exec-4] DEBUG org.hibernate.engine.jdbc.internal.LogicalConnectionImpl  - Obtaining JDBC connection

      2017-04-04 17:49:01,382 [http-bio-8080-exec-4] DEBUG org.hibernate.engine.jdbc.internal.LogicalConnectionImpl  - Obtained JDBC connection

      2017-04-04 17:49:01,529 [http-bio-8080-exec-4] DEBUG org.hibernate.loader.Loader  - Done entity load

      2017-04-04 17:49:01,530 [http-bio-8080-exec-4] DEBUG org.hibernate.SQL  - select SEAM_TASKID_SEQ.nextval from dual

      2017-04-04 17:49:01,603 [http-bio-8080-exec-4] DEBUG org.hibernate.id.SequenceGenerator  - Sequence identifier generated: BasicHolder[java.lang.Long[26]]

      2017-04-04 17:49:01,603 [http-bio-8080-exec-4] DEBUG org.hibernate.event.internal.AbstractSaveEventListener  - Generated identifier: 26, using strategy: org.hibernate.id.SequenceGenerator

      2017-04-04 17:49:01,604 [http-bio-8080-exec-4] ERROR org.springframework.transaction.support.TransactionSynchronizationUtils  - TransactionSynchronization.beforeCompletion threw exception

      javax.persistence.TransactionRequiredException: no transaction is in progress

          at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:993)

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

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

          at java.lang.reflect.Method.invoke(Method.java:497)

          at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:344)

          at com.sun.proxy.$Proxy91.flush(Unknown Source)

          at org.drools.persistence.jpa.marshaller.JPAPlaceholderResolverStrategy.marshal(JPAPlaceholderResolverStrategy.java:97)

          at org.jbpm.marshalling.impl.ProtobufProcessMarshaller.marshallVariable(ProtobufProcessMarshaller.java:244)

          at org.jbpm.marshalling.impl.AbstractProtobufProcessInstanceMarshaller.writeProcessInstance(AbstractProtobufProcessInstanceMarshaller.java:138)

          at org.jbpm.marshalling.impl.AbstractProtobufProcessInstanceMarshaller.writeProcessInstance(AbstractProtobufProcessInstanceMarshaller.java:62)

          at org.jbpm.persistence.processinstance.ProcessInstanceInfo.transform(ProcessInstanceInfo.java:217)

          at org.drools.persistence.TriggerUpdateTransactionSynchronization.beforeCompletion(TriggerUpdateTransactionSynchronization.java:42)

          at org.kie.spring.persistence.SpringTransactionSynchronizationAdapter.beforeCompletion(SpringTransactionSynchronizationAdapter.java:54)

          at org.springframework.transaction.support.TransactionSynchronizationUtils.triggerBeforeCompletion(TransactionSynchronizationUtils.java:106)

          at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerBeforeCompletion(AbstractPlatformTransactionManager.java:941)

          at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:741)

          at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:726)

          at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:521)

          at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:291)

          at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)

          at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

          at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)

          at cotown.lib.workflow.resource.rest.seam.SEAMTaskService$$EnhancerBySpringCGLIB$$893dcdd3.fresh(<generated>)

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

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

          at java.lang.reflect.Method.invoke(Method.java:497)

          at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)

          at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)

          at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)

          at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)

          at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)

          at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)

          at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)

          at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)

          at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542)

          at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473)

          at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)

          at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)

          at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)

          at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558)

          at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733)

          at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)

          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

          at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

          at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:98)

          at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

          at cotown.lib.services.session.RequestInspectorFilter.doFilter(RequestInspectorFilter.java:101)

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

          at org.apache.catalina.filters.CorsFilter.handleSimpleCORS(CorsFilter.java:302)

          at org.apache.catalina.filters.CorsFilter.doFilter(CorsFilter.java:166)

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)

          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)

          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)

          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)

          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)

          at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)

          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)

          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)

          at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)

          at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)

          at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)

          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

          at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

          at java.lang.Thread.run(Thread.java:745)