[jboss-user] [jBPM Users] - How to use timers?

mauromol do-not-reply at jboss.com
Mon Nov 23 10:37:29 EST 2009


Hello all,
I spent some hours now trying to get a simple timer use-case to work using jBPM 3 with no success. I did a lot of search to find solutions and I could make some very little progress, but I think I'm doing something wrong again.

First of all: is there any documentation on it? The jBPM 3 user guide explains something like NOTHING on this subject...

First of all, my environment:

- jBPM Version : 3.3.0GA
- Database : none, working with a unit test
- JDK : 1.5.0_15
- Container : none
- Configuration : no custom configuration used
- Libraries : no custom libraries used

=== Process ==================================

PROCESS DEFINITION:


  | <?xml version="1.0" encoding="UTF-8"?>
  | 
  | <process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="simple">
  | 	<start-state name="start">
  | 		<transition name="to_state" to="first">
  | 			<action name="action" class="com.sample.action.MessageActionHandler">
  | 				<message>Going to the first state!</message>
  | 			</action>
  | 		</transition>
  | 	</start-state>
  | 	<state name="first">
  | 		<timer duedate="5 seconds" name="Timer1" transition="to_end">
  | 			<action class="com.sample.action.TimerActionHandler" name="TimerAction"></action>
  | 		</timer>
  | 		<transition name="to_end" to="end">
  | 			<action name="action" class="com.sample.action.MessageActionHandler">
  | 				<message>About to finish!</message>
  | 			</action>
  | 		</transition>
  | 	</state>
  | 	<end-state name="end"></end-state>
  | </process-definition>
  | 

TIMER ACTION HANDLER:


  | package com.sample.action;
  | 
  | import org.jbpm.graph.def.ActionHandler;
  | import org.jbpm.graph.exe.ExecutionContext;
  | 
  | public class TimerActionHandler implements ActionHandler
  | {
  | 	public TimerActionHandler()
  | 	{
  | 		System.out.println("TimerActionHandler created");
  | 	}
  | 
  | 	public void execute(ExecutionContext executionContext) throws Exception
  | 	{
  | 		System.out.println("Executing timer action");
  | 		// signal
  | 		executionContext.getProcessInstance().signal();
  | 	}
  | }
  | 

TEST CASE SOURCE:

TRIAL 1 (see problem description):

  | package com.sample;
  | 
  | import junit.framework.TestCase;
  | 
  | import org.jbpm.graph.def.ProcessDefinition;
  | import org.jbpm.graph.exe.ProcessInstance;
  | 
  | public class SimpleProcessTest extends TestCase
  | {
  | 
  | 	public void testSimpleProcess() throws Exception
  | 	{
  | 
  | 		// Extract a process definition from the processdefinition.xml file.
  | 		ProcessDefinition processDefinition =
  | 		  ProcessDefinition.parseXmlResource("simple/processdefinition.xml");
  | 		assertNotNull("Definition should not be null", processDefinition);
  | 
  | 		// Create an instance of the process definition.
  | 		ProcessInstance instance = new ProcessInstance(processDefinition);
  | 		assertEquals("Instance is in start state", instance.getRootToken()
  | 		  .getNode().getName(), "start");
  | 		assertNull("Message variable should not exist yet", instance
  | 		  .getContextInstance().getVariable("message"));
  | 
  | 		// Move the process instance from its start state to the first state.
  | 		// The configured action should execute and the appropriate message
  | 		// should appear in the message process variable.
  | 		instance.signal();
  | 		assertEquals("Instance is in first state", instance.getRootToken()
  | 		  .getNode().getName(), "first");
  | 		assertEquals("Message variable contains message", instance
  | 		  .getContextInstance().getVariable("message"), "Going to the first state!");
  | 
  | 		// process should move to the end sate thanks to the timer action
  | 
  | 		// // Move the process instance to the end state. The configured action
  | 		// // should execute again. The message variable contains a new value.
  | 		// instance.signal();
  | 		// assertEquals(
  | 		// "Instance is in end state",
  | 		// instance.getRootToken().getNode().getName(),
  | 		// "end");
  | 		// assertTrue("Instance has ended", instance.hasEnded());
  | 		// assertEquals(
  | 		// "Message variable is changed",
  | 		// instance.getContextInstance().getVariable("message"),
  | 		// "About to finish!");
  | 
  | 	}
  | 
  | } 
  | 

##############

TRIAL 2 (see problem description):


  | package com.sample;
  | 
  | import junit.framework.TestCase;
  | 
  | import org.jbpm.JbpmConfiguration;
  | import org.jbpm.JbpmContext;
  | import org.jbpm.graph.def.ProcessDefinition;
  | import org.jbpm.graph.exe.ProcessInstance;
  | 
  | public class SimpleProcessTest extends TestCase
  | {
  | 
  | 	public void testSimpleProcess() throws Exception
  | 	{
  | 
  | 		JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
  | 		JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
  | 
  | 		try
  | 		{
  | 			// Extract a process definition from the processdefinition.xml file.
  | 			ProcessDefinition processDefinition =
  | 			  ProcessDefinition.parseXmlResource("simple/processdefinition.xml");
  | 			assertNotNull("Definition should not be null", processDefinition);
  | 
  | 			// without this, it doesn't work!
  | 			jbpmContext.deployProcessDefinition(processDefinition);
  | 
  | 			// Create an instance of the process definition.
  | 			ProcessInstance instance = new ProcessInstance(processDefinition);
  | 			assertEquals("Instance is in start state", instance.getRootToken()
  | 			  .getNode().getName(), "start");
  | 			assertNull("Message variable should not exist yet", instance
  | 			  .getContextInstance().getVariable("message"));
  | 
  | 			// Move the process instance from its start state to the first state.
  | 			// The configured action should execute and the appropriate message
  | 			// should appear in the message process variable.
  | 			instance.signal();
  | 			assertEquals("Instance is in first state", instance.getRootToken()
  | 			  .getNode().getName(), "first");
  | 			assertEquals("Message variable contains message", instance
  | 			  .getContextInstance().getVariable("message"),
  | 			  "Going to the first state!");
  | 
  | 			// process should move to the end sate thanks to the timer action
  | 
  | 			// try to wait for the timer action to be executed
  | 			Thread.sleep(10000l);
  | 
  | 			// // Move the process instance to the end state. The configured action
  | 			// // should execute again. The message variable contains a new value.
  | 			// instance.signal();
  | 			// assertEquals(
  | 			// "Instance is in end state",
  | 			// instance.getRootToken().getNode().getName(),
  | 			// "end");
  | 			// assertTrue("Instance has ended", instance.hasEnded());
  | 			// assertEquals(
  | 			// "Message variable is changed",
  | 			// instance.getContextInstance().getVariable("message"),
  | 			// "About to finish!");
  | 
  | 		}
  | 		finally
  | 		{
  | 			jbpmContext.close();
  | 		}
  | 	}
  | 
  | }
  | 

=== Stacktrace ==============================
TRIAL 1 (see problem description):


  | org.jbpm.svc.JbpmServiceException: service 'scheduler' unavailable
  | 	at org.jbpm.svc.Services.getCurrentService(Services.java:97)
  | 	at org.jbpm.svc.Services.getCurrentService(Services.java:87)
  | 	at org.jbpm.scheduler.def.CreateTimerAction.execute(CreateTimerAction.java:79)
  | 	at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:256)
  | 	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.Node.enter(Node.java:298)
  | 	at org.jbpm.graph.def.Transition.take(Transition.java:151)
  | 	at org.jbpm.graph.def.Node.leave(Node.java:389)
  | 	at org.jbpm.graph.node.StartState.leave(StartState.java:70)
  | 	at org.jbpm.graph.exe.Token.signal(Token.java:192)
  | 	at org.jbpm.graph.exe.Token.signal(Token.java:140)
  | 	at org.jbpm.graph.exe.ProcessInstance.signal(ProcessInstance.java:271)
  | 	at com.sample.SimpleProcessTest.testSimpleProcess(SimpleProcessTest.java:29)
  | 	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 junit.framework.TestCase.runTest(TestCase.java:154)
  | 	at junit.framework.TestCase.runBare(TestCase.java:127)
  | 	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:118)
  | 	at junit.framework.TestSuite.runTest(TestSuite.java:208)
  | 	at junit.framework.TestSuite.run(TestSuite.java:203)
  | 	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)
  | 

##############

TRIAL 2 (before creating an own context, see problem description):


  | java.lang.NoClassDefFoundError: javax/transaction/Synchronization
  | 	at org.hibernate.impl.SessionImpl.<init>(SessionImpl.java:213)
  | 	at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:473)
  | 	at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:497)
  | 	at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:505)
  | 	at org.jbpm.persistence.db.DbPersistenceService.getSession(DbPersistenceService.java:117)
  | 	at org.jbpm.persistence.db.DbPersistenceService.getJobSession(DbPersistenceService.java:369)
  | 	at org.jbpm.JbpmContext.getJobSession(JbpmContext.java:630)
  | 	at org.jbpm.scheduler.db.DbSchedulerService.<init>(DbSchedulerService.java:50)
  | 	at org.jbpm.scheduler.db.DbSchedulerServiceFactory.openService(DbSchedulerServiceFactory.java:32)
  | 	at org.jbpm.svc.Services.getService(Services.java:156)
  | 	at org.jbpm.svc.Services.getCurrentService(Services.java:94)
  | 	at org.jbpm.svc.Services.getCurrentService(Services.java:87)
  | 	at org.jbpm.scheduler.def.CreateTimerAction.execute(CreateTimerAction.java:79)
  | 	at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:256)
  | 	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.Node.enter(Node.java:298)
  | 	at org.jbpm.graph.def.Transition.take(Transition.java:151)
  | 	at org.jbpm.graph.def.Node.leave(Node.java:389)
  | 	at org.jbpm.graph.node.StartState.leave(StartState.java:70)
  | 	at org.jbpm.graph.exe.Token.signal(Token.java:192)
  | 	at org.jbpm.graph.exe.Token.signal(Token.java:140)
  | 	at org.jbpm.graph.exe.ProcessInstance.signal(ProcessInstance.java:271)
  | 	at com.sample.SimpleProcessTest.testSimpleProcess(SimpleProcessTest.java:36)
  | 	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 junit.framework.TestCase.runTest(TestCase.java:154)
  | 	at junit.framework.TestCase.runBare(TestCase.java:127)
  | 	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:118)
  | 	at junit.framework.TestSuite.runTest(TestSuite.java:208)
  | 	at junit.framework.TestSuite.run(TestSuite.java:203)
  | 	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)
  | 

=== Debug logs ==============================

TRIAL 1 (see problem description):


  | [INFO ] 2009/11/23 15:53:48 - main - org.jbpm.JbpmConfiguration - using jbpm configuration resource 'jbpm.cfg.xml'
  | [DEBUG] 2009/11/23 15:53:48 - main - org.jbpm.JbpmConfiguration - loading defaults in jbpm configuration
  | [DEBUG] 2009/11/23 15:53:48 - main - org.jbpm.configuration.ObjectFactoryImpl - adding object info 'default.jbpm.context'
  | [DEBUG] 2009/11/23 15:53:48 - main - org.jbpm.configuration.ObjectFactoryImpl - adding object info 'resource.hibernate.cfg.xml'
  | [DEBUG] 2009/11/23 15:53:48 - main - org.jbpm.configuration.ObjectFactoryImpl - adding object info 'resource.business.calendar'
  | [DEBUG] 2009/11/23 15:53:48 - main - org.jbpm.configuration.ObjectFactoryImpl - adding object info 'resource.default.modules'
  | [DEBUG] 2009/11/23 15:53:48 - main - org.jbpm.configuration.ObjectFactoryImpl - adding object info 'resource.converter'
  | [DEBUG] 2009/11/23 15:53:48 - main - org.jbpm.configuration.ObjectFactoryImpl - adding object info 'resource.action.types'
  | [DEBUG] 2009/11/23 15:53:48 - main - org.jbpm.configuration.ObjectFactoryImpl - adding object info 'resource.node.types'
  | [DEBUG] 2009/11/23 15:53:48 - main - org.jbpm.configuration.ObjectFactoryImpl - adding object info 'resource.parsers'
  | [DEBUG] 2009/11/23 15:53:48 - main - org.jbpm.configuration.ObjectFactoryImpl - adding object info 'resource.varmapping'
  | [DEBUG] 2009/11/23 15:53:48 - main - org.jbpm.configuration.ObjectFactoryImpl - adding object info 'resource.mail.templates'
  | [DEBUG] 2009/11/23 15:53:48 - main - org.jbpm.configuration.ObjectFactoryImpl - adding object info 'jbpm.byte.block.size'
  | [DEBUG] 2009/11/23 15:53:48 - main - org.jbpm.configuration.ObjectFactoryImpl - adding object info 'jbpm.task.instance.factory'
  | [DEBUG] 2009/11/23 15:53:48 - main - org.jbpm.configuration.ObjectFactoryImpl - adding object info 'jbpm.variable.resolver'
  | [DEBUG] 2009/11/23 15:53:48 - main - org.jbpm.configuration.ObjectFactoryImpl - adding object info 'jbpm.mail.smtp.host'
  | [DEBUG] 2009/11/23 15:53:48 - main - org.jbpm.configuration.ObjectFactoryImpl - adding object info 'jbpm.mail.address.resolver'
  | [DEBUG] 2009/11/23 15:53:48 - main - org.jbpm.configuration.ObjectFactoryImpl - adding object info 'jbpm.mail.from.address'
  | [DEBUG] 2009/11/23 15:53:48 - main - org.jbpm.configuration.ObjectFactoryImpl - adding object info 'jbpm.job.executor'
  | [DEBUG] 2009/11/23 15:53:48 - main - org.jbpm.JbpmConfiguration - loading specific configuration...
  | [DEBUG] 2009/11/23 15:53:48 - main - org.jbpm.configuration.ObjectFactoryImpl - adding object info 'jbpmConfiguration'
  | [INFO ] 2009/11/23 15:53:48 - main - org.jbpm.persistence.db.StaleObjectLogConfigurer - stale object exceptions will be hidden from logging
  | [DEBUG] 2009/11/23 15:53:48 - main - org.jbpm.jpdl.xml.JpdlParser - schema resource found: org/jbpm/jpdl/xml/jpdl-3.3.xsd
  | [DEBUG] 2009/11/23 15:53:48 - main - org.jbpm.jpdl.xml.JpdlParser - schema resource found: org/jbpm/jpdl/xml/jpdl-3.1.xsd
  | [DEBUG] 2009/11/23 15:53:48 - main - org.jbpm.jpdl.xml.JpdlParser - schema resource found: org/jbpm/jpdl/xml/jpdl-3.0.xsd
  | [DEBUG] 2009/11/23 15:53:48 - main - org.jbpm.jpdl.xml.JpdlParser - schema resource found: org/jbpm/jpdl/xml/jpdl-3.2.xsd
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.graph.node.NodeTypes - node 'page' will not be available. class 'org.jboss.seam.pageflow.Page' couldn't be loaded
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.graph.node.NodeTypes - node 'start-page' will not be available. class 'org.jboss.seam.pageflow.Page' couldn't be loaded
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.graph.def.GraphElement - event 'process-start' on 'ProcessDefinition(simple)' for 'Token(/)'
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.graph.def.GraphElement - event 'before-signal' on 'StartState(start)' for 'Token(/)'
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.graph.def.GraphElement - event 'node-leave' on 'StartState(start)' for 'Token(/)'
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.graph.def.GraphElement - event 'transition' on 'Transition(to_state)' for 'Token(/)'
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.graph.def.GraphElement - executing action 'action[action]'
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.graph.exe.Token - token[0] is locked by token[0]
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.context.exe.VariableContainer - create variable 'message' in 'TokenVariableMap10ad8659' with value 'Going to the first state!'
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.db.hibernate.Converters - adding converter 'D', 'org.jbpm.context.exe.converter.DoubleToStringConverter'
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.db.hibernate.Converters - adding converter 'C', 'org.jbpm.context.exe.converter.CharacterToStringConverter'
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.db.hibernate.Converters - adding converter 'B', 'org.jbpm.context.exe.converter.BooleanToStringConverter'
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.db.hibernate.Converters - adding converter 'Y', 'org.jbpm.context.exe.converter.BytesToByteArrayConverter'
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.db.hibernate.Converters - adding converter 'A', 'org.jbpm.context.exe.converter.DateToLongConverter'
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.db.hibernate.Converters - adding converter 'R', 'org.jbpm.context.exe.converter.SerializableToByteArrayConverter'
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.db.hibernate.Converters - adding converter 'I', 'org.jbpm.context.exe.converter.IntegerToLongConverter'
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.db.hibernate.Converters - adding converter 'H', 'org.jbpm.context.exe.converter.ShortToLongConverter'
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.db.hibernate.Converters - adding converter 'G', 'org.jbpm.context.exe.converter.FloatToDoubleConverter'
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.db.hibernate.Converters - adding converter 'F', 'org.jbpm.context.exe.converter.FloatToStringConverter'
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.db.hibernate.Converters - adding converter 'E', 'org.jbpm.context.exe.converter.ByteToLongConverter'
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.graph.exe.Token - token[0] is unlocked by token[0]
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.graph.def.GraphElement - event 'node-enter' on 'State(first)' for 'Token(/)'
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.graph.def.GraphElement - executing action 'CreateTimerAction(5d6d2633)'
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.graph.exe.Token - token[0] is locked by token[0]
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.graph.def.GraphElement - event 'timer-create' on 'State(first)' for 'Token(/)'
  | [DEBUG] 2009/11/23 15:53:49 - main - org.jbpm.graph.exe.Token - token[0] is unlocked by token[0]
  | [ERROR] 2009/11/23 15:53:49 - main - org.jbpm.graph.def.GraphElement - action threw exception: service 'scheduler' unavailable
  | 

##############

TRIAL 2 (see problem description):

Too long to attach here, please click ftp://guest:guest@mauromol.dyndns.org/part0/public/jbpm.log

=== Problem description =========================

As you can see from the attached test cases, you can get to TRIAL 1 scenario by doing the following:
- create new process project and leave the wizard create the standard example process, classes and handlers for you; a new sample process will be created with a "start" node, a "first" state node and an "end" node
- change the SimpleProcessTest class so that a new Timer is defined at the "first" state, configured to call and action handler (TimerActionHandler) after 3 seconds; this action handler, when invoked, prints a message on the standard output and then does the actual signal to the process instance, to reach the end state

The first problem I encounter is a "service 'scheduler' unavailable" error. Searching on the net I found some hints like "start the scheduler" or "change the configuration in src/main/config/jbpm.cfg.xml. But nobody explains WHAT is the scheduler, how to start it, etc.. However, after some trials and debugging sessions I found that the solution to this problem is another one: you need to create a JbpmContext by yourself:


  | JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
  | JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
  | try
  | {
  |   // test case code here
  | }
  | finally
  | {
  |   jbpmContext.close();
  | }
  | 

This because org.jbpm.svc.Services.getCurrentService(String, boolean) fails if there's no current JbpmContext... This is obviously a bug, otherwise I can't understand why the test case works if I remove the timer... Moreover, as I said, the test case is the built-in one...

Anyway, now let's switch to TRIAL 2. In this case I did what I just explained, but I get an error related to the fact that Hibernate is searching for a JTA class... However, as I'm working with no database at all, I wouldn't expect that. Anyway, by adding JTA classes to the project build path I now get another Hibernate error: commit failed because "object references an unsaved transient instance - save the transient instance before flushing: org.jbpm.graph.exe.ProcessInstance".
After searching again on the Internet I could find that the "secret" here is to deploy the process definition after it is created by parsing the XML. By doing that, no exception is thrown!

But now... how to test the timer action? In my test case it isn't ever executed. I can even place a Thread.sleep(10000l) to make the JUnit runner wait for 10 seconds, but the timer action is not executed anyway.

How should it work?

Thanks in advance for any help.

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4267065#4267065

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4267065



More information about the jboss-user mailing list