2 Replies Latest reply on Jun 25, 2007 11:52 AM by Gavin King

    jBPM processInstance question

    Xinhua Gu Newbie

      hi,
      i want to inject processInstance in action after @CreateProcess like following code:

      @Name("printSthAction")
      @AutoCreate
      public class PrintSthAction {
       @Logger Log log;
      
       @In
       private String content;
      
       @In
       ProcessInstance processInstance;
      
      
       public void printout(){
       log.info("=============> process Instance is null? #0", processInstance);
       log.info("=============> print #0", content);
       }
      
      }


      jPDL:
      <?xml version="1.0"?>
      
      <process-definition name="test">
      
       <start-state name="start">
       <transition name="printout" to="complete">
       <action expression="#{printSthAction.printout}"/>
       </transition>
       </start-state>
      
       <end-state name="complete" />
      
      </process-definition>


      But, i got an exception like this:
      10:31:53,653 ERROR [GraphElement] action threw exception: couldn't evaluate expression '#{printSthAction.printout}'
      org.jbpm.JbpmException: couldn't evaluate expression '#{printSthAction.printout}'
       at org.jbpm.jpdl.el.impl.JbpmExpressionEvaluator.evaluate(JbpmExpressionEvaluator.java:52)
       at org.jbpm.graph.def.Action.execute(Action.java:119)
       at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:235)
       at org.jbpm.graph.def.GraphElement.executeActions(GraphElement.java:212)
       at org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.java:182)
       at org.jbpm.graph.def.GraphElement.fireEvent(GraphElement.java:166)
       at org.jbpm.graph.def.Transition.take(Transition.java:106)
       at org.jbpm.graph.def.Node.leave(Node.java:383)
       at org.jbpm.graph.node.StartState.leave(StartState.java:70)
       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:585)
       at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:173)
       at org.jbpm.graph.def.Node_$$_javassist_432.leave(Node_$$_javassist_432.java)
       at org.jbpm.graph.exe.Token.signal(Token.java:178)
       at org.jbpm.graph.exe.Token.signal(Token.java:123)
       at org.jbpm.graph.exe.ProcessInstance.signal(ProcessInstance.java:217)
       at org.jboss.seam.core.BusinessProcess.createProcess(BusinessProcess.java:116)
       at org.jboss.seam.interceptors.BusinessProcessInterceptor.afterInvocation(BusinessProcessInterceptor.java:98)
       at org.jboss.seam.interceptors.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:50)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
       at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:151)
       at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:87)
       at de.strato.bussiness.schedular.job.AutoProcessJob2_$$_javassist_477.excute(AutoProcessJob2_$$_javassist_477.java)
       at de.strato.bussiness.schedular.QuartzTimeServiceBean.startProccess(QuartzTimeServiceBean.java:42)
       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:585)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
       at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:37)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
       at org.jboss.seam.interceptors.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:50)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
       at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:53)
       at sun.reflect.GeneratedMethodAccessor718.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
       at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
       at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:214)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:184)
       at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:81)
       at $Proxy428.startProccess(Unknown Source)
       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:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
       at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
       at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:72)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
       at org.jboss.seam.interceptors.AsynchronousInterceptor.aroundInvoke(AsynchronousInterceptor.java:35)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
       at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:50)
       at org.javassist.tmp.java.lang.Object_$$_javassist_475.startProccess(Object_$$_javassist_475.java)
       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:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
       at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:124)
       at org.jboss.seam.core.AbstractDispatcher$AsynchronousInvocation.call(AbstractDispatcher.java:126)
       at org.jboss.seam.core.AbstractDispatcher$Asynchronous.execute(AbstractDispatcher.java:75)
       at org.jboss.seam.core.QuartzDispatcher$QuartzJob.execute(QuartzDispatcher.java:242)
       at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
       at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529)
      Caused by: java.lang.IllegalArgumentException: could not set field value: printSthAction.processInstance
       at org.jboss.seam.Component.setFieldValue(Component.java:1629)
       at org.jboss.seam.Component.access$500(Component.java:137)
       at org.jboss.seam.Component$BijectedField.set(Component.java:2355)
       at org.jboss.seam.Component.injectAttributes(Component.java:1438)
       at org.jboss.seam.Component.inject(Component.java:1262)
       at org.jboss.seam.interceptors.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.interceptors.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:50)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
       at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:151)
       at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:87)
       at de.strato.bussiness.process.action.PrintSthAction_$$_javassist_479.printout(PrintSthAction_$$_javassist_479.java)
       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:585)
       at org.jbpm.jpdl.el.impl.BeanMethod.invoke(BeanMethod.java:19)
       at org.jbpm.jpdl.el.impl.ArraySuffix.evaluate(ArraySuffix.java:287)
       at org.jbpm.jpdl.el.impl.ComplexValue.evaluate(ComplexValue.java:146)
       at org.jbpm.jpdl.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:264)
       at org.jbpm.jpdl.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:191)
       at org.jbpm.jpdl.el.impl.JbpmExpressionEvaluator.evaluate(JbpmExpressionEvaluator.java:48)
       ... 94 more
      Caused by: java.lang.IllegalArgumentException: Could not set field value by reflection: PrintSthAction.processInstance on: de.strato.bussiness.process.action.Pr
      intSthAction with value: class org.jbpm.graph.exe.ProcessInstance
       at org.jboss.seam.util.Reflections.set(Reflections.java:78)
       at org.jboss.seam.Component.setFieldValue(Component.java:1625)
       ... 118 more
      Caused by: java.lang.IllegalArgumentException
       at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
       at java.lang.reflect.Field.set(Field.java:656)
       at org.jboss.seam.util.Reflections.set(Reflections.java:64)
       ... 119 more
       ... 119 more
      10:17:59,713 WARN [JDBCExceptionReporter] SQL Error: -177, SQLState: 23000
      10:17:59,713 ERROR [JDBCExceptionReporter] Integrity constraint violation - no parent FK_MODINST_PRCINST table: JBPM_PROCESSINSTANCE in statement [insert into J
      BPM_MODULEINSTANCE (ID_, PROCESSINSTANCE_, TASKMGMTDEFINITION_, CLASS_) values (null, ?, ?, 'T')]
      10:17:59,713 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_2] TwoPhaseCoordinator.beforeCompletion - failed for com.arjuna.ats.in
      ternal.jta.resources.arjunacore.SynchronizationImple@1561b1a
      org.hibernate.exception.ConstraintViolationException: could not insert: [org.jbpm.taskmgmt.exe.TaskMgmtInstance]
       at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
       at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
       at org.hibernate.id.insert.AbstractSelectingDelegate.performInsert(AbstractSelectingDelegate.java:40)
       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2158)
       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2638)
       at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:48)
       at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
       at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298)
       at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
       at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107)
       at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
       at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
       at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
       at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
       at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
       at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
       at org.hibernate.engine.CascadingAction$1.cascade(CascadingAction.java:218)
       at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
       at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
       at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
       at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296)
       at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242)
       at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219)
       at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
       at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
       at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131)
       at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:122)
       at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65)
       at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
       at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
       at org.jboss.seam.core.ManagedJbpmContext.beforeCompletion(ManagedJbpmContext.java:94)
       at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114)
       at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:249)
       at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:88)
       at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
       at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1256)
       at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135)
       at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)
       at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:140)
       at org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:35)
       at org.jboss.seam.util.Work.workInTransaction(Work.java:42)
       at org.jboss.seam.core.ProcessInstance.getProcessInstance(ProcessInstance.java:41)
       at sun.reflect.GeneratedMethodAccessor752.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
       at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:124)
       at org.jboss.seam.Component.callComponentMethod(Component.java:1904)
       at org.jboss.seam.Component.unwrap(Component.java:1930)
       at org.jboss.seam.Component.getInstance(Component.java:1727)
       at org.jboss.seam.Component.getInstance(Component.java:1692)
       at org.jboss.seam.Component.getInstance(Component.java:1669)
       at org.jboss.seam.Component.getInstance(Component.java:1664)
       at org.jboss.seam.core.ProcessInstance.instance(ProcessInstance.java:67)
       at org.jboss.seam.contexts.BusinessProcessContext.getProcessInstance(BusinessProcessContext.java:219)
       at org.jboss.seam.contexts.BusinessProcessContext.getContextInstance(BusinessProcessContext.java:206)
       at org.jboss.seam.contexts.BusinessProcessContext.get(BusinessProcessContext.java:56)
       at org.jboss.seam.contexts.Contexts.lookupInStatefulContexts(Contexts.java:191)
       at org.jboss.seam.Component.getInstance(Component.java:1679)
       at org.jboss.seam.Component.getInstance(Component.java:1674)
       at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:57)
       at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
       at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
       at org.jboss.el.parser.AstValue.getTarget(AstValue.java:34)
       at org.jboss.el.parser.AstValue.invoke(AstValue.java:95)
       at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
       at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:157)
       at org.jboss.seam.core.Events.raiseEvent(Events.java:64)
       at org.jboss.seam.contexts.Contexts.destroy(Contexts.java:215)
       at org.jboss.seam.contexts.Lifecycle.endCall(Lifecycle.java:80)
       at org.jboss.seam.core.AbstractDispatcher$Asynchronous.execute(AbstractDispatcher.java:81)
       at org.jboss.seam.core.QuartzDispatcher$QuartzJob.execute(QuartzDispatcher.java:242)
       at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
       at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529)
      Caused by: java.sql.SQLException: Integrity constraint violation - no parent FK_MODINST_PRCINST table: JBPM_PROCESSINSTANCE in statement [insert into JBPM_MODUL
      EINSTANCE (ID_, PROCESSINSTANCE_, TASKMGMTDEFINITION_, CLASS_) values (null, ?, ?, 'T')]
       at org.hsqldb.jdbc.Util.throwError(Unknown Source)
       at org.hsqldb.jdbc.jdbcPreparedStatement.executeUpdate(Unknown Source)
       at org.jboss.resource.adapter.jdbc.CachedPreparedStatement.executeUpdate(CachedPreparedStatement.java:95)
       at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:251)
       at org.hibernate.id.insert.AbstractSelectingDelegate.performInsert(AbstractSelectingDelegate.java:33)
       ... 71 more
      


      can anyone help me? Thanks.

        • 1. Re: jBPM processInstance question
          Xinhua Gu Newbie

          i found a solution:

          @Name("printSthAction")
          @AutoCreate
          public class PrintSthAction {
           @Logger Log log;
          
           @In
           private String content;
          
           @In
           private BusinessProcess businessProcess;
          
           @In
           private JbpmContext jbpmContext;
          
           public void printout(){
          
           log.info("=============> process Instance is null? #0", jbpmContext.getProcessInstance(businessProcess.getProcessId()));
           log.info("=============> print out sth: #0", content);
           }
          
          }
          


          Maybe it is not a good way, but i got what i want :D

          • 2. Re: jBPM processInstance question
            Gavin King Master

            Make sure you imported the correct class named ProcessInstance - not org.jboss.seam.core.ProcessInstance, that is not the right one!