[jbpm-issues] [JBoss JIRA] Commented: (JBPM-2711) Subprocess waiting at <state> or <custom> throws JbpmException 'is not active: inactive-scope' even though isActive() returns true and findActiveActivityNames() returns the correct active state activity - Addition of <timer> on transition seems the cause.

Ronald van Kuijk (JIRA) jira-events at lists.jboss.org
Wed Jan 6 15:49:30 EST 2010


    [ https://jira.jboss.org/jira/browse/JBPM-2711?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12502583#action_12502583 ] 

Ronald van Kuijk commented on JBPM-2711:
----------------------------------------

Ok, I can confirm that adding a timer on a state in an async subprocess changes the state from async to 'inactive-scope'. In the first state it can be signalled, in the latter it can't and you can only signal the active execution.

I even confirmed this in a very small test in TestTimer.java. Play with it, going to mark this issue as invalid.

package org.jbpm.test.timer;

import java.util.Calendar;
import java.util.Map;
import java.util.Set;

import org.jbpm.api.Execution;
import org.jbpm.api.JbpmException;
import org.jbpm.api.ProcessInstance;
import org.jbpm.api.activity.ActivityExecution;
import org.jbpm.api.activity.ExternalActivityBehaviour;
import org.jbpm.api.job.Job;
import org.jbpm.api.listener.EventListener;
import org.jbpm.api.listener.EventListenerExecution;
import org.jbpm.test.JbpmTestCase;
import org.jbpm.test.activity.custom.CustomConfigurationsTest.MyCustomWait;

/**
 * @author Ronald van Kuijk
 */
public class TimerTest extends JbpmTestCase {

	public void testTimerTimeoutCustom() {
		deployJpdlXmlString("<process name='Insurance claim' key='ICL2'>"
				+ "  <start>" + "    <transition to='a' />" + "  </start>"
				+ "  <custom continue='async' name='a' class='"
				+ MyCustomWait.class.getName() + "'>"
				+ "    <transition to='b' />"
				+ "    <transition name='timeout' to='escalate'>"
				+ "      <event-listener class='"
				+ MyCustomWait.class.getName() + "'/>"
				+ "      <timer duedate='2 minutes' />" + "    </transition>"
				+ "  </custom>" + "  <state name='b' />"
				+ "  <end name='escalate' />" + "</process>");

		ProcessInstance processInstance = executionService
				.startProcessInstanceByKey("ICL2", "82436");

		assertEquals(Execution.STATE_INACTIVE_SCOPE, processInstance.getState());

		assertNotActivityActive(processInstance.getId(), "a");

		// execute the async state so it becomes active
		Job async = managementService.createJobQuery().messages()
				.processInstanceId(processInstance.getId()).uniqueResult();
		managementService.executeJob(async.getId());

		assertActivityActive(processInstance.getId(), "a");

		try {
			executionService.signalExecutionById(processInstance.getId());
			fail("Should not happen, exception expected");
		} catch (JbpmException e) {
			// Should happen....Signalling an inactive-scope exexcution is not
			// allowed. If the timer is removed, this test should fail since the
			// state of the execution is async then and signalling that is
			// allowed. 
		}

		assertProcessInstanceActive(processInstance);

		executionService.signalExecutionById(processInstance.getExecution("a")
				.getId());

		assertActivityActive(processInstance.getId(), "b");

	}

	public void testTimerSignalCustom() {
		deployJpdlXmlString("<process name='Insurance claim' key='ICL2'>"
				+ "  <start>" + "    <transition to='a' />" + "  </start>"
				+ "  <custom continue='async' name='a' class='"
				+ MyCustomWait.class.getName() + "'>"
				+ "    <transition to='b' />"
				+ "    <transition name='timeout' to='escalate'>"
				+ "      <event-listener class='"
				+ MyCustomWait.class.getName() + "'/>"
				+ "      <timer duedate='2 minutes' />" + "    </transition>"
				+ "  </custom>" + "  <state name='b' />"
				+ "  <end name='escalate' />" + "</process>");

		ProcessInstance processInstance = executionService
				.startProcessInstanceByKey("ICL2", "82436");

		assertEquals(Execution.STATE_INACTIVE_SCOPE, processInstance.getState());

		assertNotActivityActive(processInstance.getId(), "a");

		// execute the async state so it becomes active
		Job async = managementService.createJobQuery().messages()
				.processInstanceId(processInstance.getId()).uniqueResult();
		managementService.executeJob(async.getId());

		assertActivityActive(processInstance.getId(), "a");

		// Execute the timer
		Job job = managementService.createJobQuery().timers()
				.processInstanceId(processInstance.getId()).uniqueResult();
		managementService.executeJob(job.getId());

		assertProcessInstanceEnded(processInstance);
	}

	public static class MyCustomWait implements ExternalActivityBehaviour,
			EventListener {

		private static final long serialVersionUID = 1L;

		public void execute(ActivityExecution execution) throws Exception {
			execution.waitForSignal();
		}

		public void signal(ActivityExecution execution, String signalName,
				Map<String, ?> parameters) throws Exception {
			execution.take(signalName);
		}

		public void notify(EventListenerExecution execution) throws Exception {
			log.debug("Timer went off, taking transition");
		}
	}
}

> Subprocess waiting at <state> or <custom> throws JbpmException 'is not active: inactive-scope' even though isActive() returns true and findActiveActivityNames() returns the correct active state activity - Addition of <timer> on transition seems the cause.
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: JBPM-2711
>                 URL: https://jira.jboss.org/jira/browse/JBPM-2711
>             Project: jBPM
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: Runtime Engine
>    Affects Versions: jBPM 4.3
>         Environment: Eclipse 3.5, Oracle 11g, jBPM 4.3 & jBPM 4.2
>            Reporter: Martin Porter
>         Attachments: jira-jbpm2711.zip
>
>
> I have a sub-process that is waiting at a <state> activity. If I attempt to signal that activity using the subprocess id I get an exception with 'inactive scope'. Below is the code I am using to signal the activity and also the output (system.out) to show the status:-
> ProcessDefinition childProcessDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("org.jbpm.examples.subprocess.usecase.waitstate.child").uniqueResult();
> ProcessInstanceQuery query = executionService.createProcessInstanceQuery().processDefinitionId(childProcessDefinition.getId());
> ProcessInstance childInstance = query.uniqueResult();
> System.out.println("Found Child Process Instance With Id [" + childInstance.getId() + "]");	
> System.out.println("Is Active ? " + childInstance.isActive("Business Service Response Handler"));
> System.out.println("State = " + childInstance.getState());
> Set<String> activities = childInstance.findActiveActivityNames();
> for (String activity : activities) {
> 	System.out.println("Active Activity = " + activity);
> }
> executionService.signalExecutionById(childInstance.getId(), AbstractServiceDispatcher.SignalState.SUCCESS.getSignalName(), params);
> And here follows the output & stack trace:-
> Found Child Process Instance With Id [org.jbpm.examples.subprocess.usecase.waitstate.child.30020]
> Is Active ? true
> State = inactive-scope
> Active Activity = Business Service Response Handler
> 11:25:30,862 FIN       | [ExecuteActivity] execution[org.jbpm.examples.subprocess.usecase.waitstate.child.30020.Business Service Response Handler] executes activity(Business Service Response Handler)
> 11:25:30,862 FIN       | [ExecuteJobCmd] executed job ExecuteActivityMessage[30054]
> 11:25:30,862 FIN       | [HibernateSessionResource] ----- committing hibernate tx 10796546 -------------------------------------------------------
> 11:25:32,828 FIN | [HibernateSessionResource] ----- beginning hibernate tx 11998234 --------------------------------------------------------
> 11:25:32,828 FIN | [HibernateSessionResource] ----- committing hibernate tx 32888473 -------------------------------------------------------
> 11:25:32,828 FIN | [HibernateSessionResource] ----- beginning hibernate tx 21290107 --------------------------------------------------------
> 11:25:32,829 FIN | [HibernateSessionResource] ----- committing hibernate tx 22589165 -------------------------------------------------------
> Found Child Process Instance With Id [org.jbpm.examples.subprocess.usecase.waitstate.child.30020]
> 11:25:32,829 FIN | [HibernateSessionResource] ----- beginning hibernate tx 23590079 --------------------------------------------------------
> ### EXCEPTION ###########################################
> 11:25:32,829 INF | [DefaultCommandService] exception while executing command org.jbpm.pvm.internal.cmd.SignalCmd at 88e83d
> org.jbpm.api.JbpmException: execution[org.jbpm.examples.subprocess.usecase.waitstate.child.30020] is not active: inactive-scope
> 	at org.jbpm.pvm.internal.model.ExecutionImpl.checkActive(ExecutionImpl.java:1024)
> 	at org.jbpm.pvm.internal.model.ExecutionImpl.signal(ExecutionImpl.java:411)
> 	at org.jbpm.pvm.internal.cmd.SignalCmd.execute(SignalCmd.java:61)
> 	at org.jbpm.pvm.internal.cmd.SignalCmd.execute(SignalCmd.java:35)
> 	at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42)
> 	at org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:54)
> 	at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53)
> 	at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)
> 	at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:55)
> 	at org.jbpm.pvm.internal.svc.SkipInterceptor.execute(SkipInterceptor.java:43)
> 	at org.jbpm.pvm.internal.svc.ExecutionServiceImpl.signalExecutionById(ExecutionServiceImpl.java:92)
> 	at org.jbpm.examples.subprocess.usecase.waitstate.SimpleSubflowUsecaseWaitStateTest.testSimpleSubflowRequestRetryThenSkipStepThenEndSuccess(SimpleSubflowUsecaseWaitStateTest.java:700)
> 	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:597)
> 	at junit.framework.TestCase.runTest(TestCase.java:164)
> 	at org.jbpm.test.BaseJbpmTestCase.runTest(BaseJbpmTestCase.java:80)
> 	at junit.framework.TestCase.runBare(TestCase.java:130)
> 	at junit.framework.TestResult$1.protect(TestResult.java:106)
> 	at junit.framework.TestResult.runProtected(TestResult.java:124)
> 	at junit.framework.TestResult.run(TestResult.java:109)
> 	at junit.framework.TestCase.run(TestCase.java:120)
> 	at junit.framework.TestSuite.runTest(TestSuite.java:230)
> 	at junit.framework.TestSuite.run(TestSuite.java:225)
> 	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
> ### EXCEPTION ###########################################
> 11:25:32,829 FIN | [HibernateSessionResource] ----- rolling back hibernate tx 4657294 -----------------------------------------------------
> 11:25:32,829 SEV | [BaseJbpmTestCase] 
> ### EXCEPTION ###########################################
> 11:25:32,829 SEV | [BaseJbpmTestCase] TEST THROWS EXCEPTION: execution[org.jbpm.examples.subprocess.usecase.waitstate.child.30020] is not active: inactive-scope
> org.jbpm.api.JbpmException: execution[org.jbpm.examples.subprocess.usecase.waitstate.child.30020] is not active: inactive-scope
> 	at org.jbpm.pvm.internal.model.ExecutionImpl.checkActive(ExecutionImpl.java:1024)
> 	at org.jbpm.pvm.internal.model.ExecutionImpl.signal(ExecutionImpl.java:411)
> 	at org.jbpm.pvm.internal.cmd.SignalCmd.execute(SignalCmd.java:61)
> 	at org.jbpm.pvm.internal.cmd.SignalCmd.execute(SignalCmd.java:35)
> 	at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42)
> 	at org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:54)
> 	at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53)
> 	at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)
> 	at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:55)
> 	at org.jbpm.pvm.internal.svc.SkipInterceptor.execute(SkipInterceptor.java:43)
> 	at org.jbpm.pvm.internal.svc.ExecutionServiceImpl.signalExecutionById(ExecutionServiceImpl.java:92)
> 	at org.jbpm.examples.subprocess.usecase.waitstate.SimpleSubflowUsecaseWaitStateTest.testSimpleSubflowRequestRetryThenSkipStepThenEndSuccess(SimpleSubflowUsecaseWaitStateTest.java:700)
> 	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:597)
> 	at junit.framework.TestCase.runTest(TestCase.java:164)
> 	at org.jbpm.test.BaseJbpmTestCase.runTest(BaseJbpmTestCase.java:80)
> 	at junit.framework.TestCase.runBare(TestCase.java:130)
> 	at junit.framework.TestResult$1.protect(TestResult.java:106)
> 	at junit.framework.TestResult.runProtected(TestResult.java:124)
> 	at junit.framework.TestResult.run(TestResult.java:109)
> 	at junit.framework.TestCase.run(TestCase.java:120)
> 	at junit.framework.TestSuite.runTest(TestSuite.java:230)
> 	at junit.framework.TestSuite.run(TestSuite.java:225)
> 	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
> ### EXCEPTION ###########################################
> 11:25:32,829 SEV | [BaseJbpmTestCase] 
> If I remove the <timer> from the transition all works as expected. I also made a change the jbpm4.3.xsd to allow the timer to be added to the transition of a <custom> node in the same way as for <state> (see http://community.jboss.org/message/518116#518116 ). The result was the same that timers worked but the signalling fails and removing the <timer> allows the signalling to work again.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jbpm-issues mailing list