[JNDI and Naming] - Re: automate jboss jndi creation
by Artec
"PeterJ" wrote : anonymous wrote : always from the console, if we modifying the DataSource is actually modified the file under the directory data / attachments /
| This statement is confusing. What console? In Jboss AS, embedded jopr is the admin console, and you just now stated that embedded jopr places datasource config files (*-ds.xml) in the server/xxx/deploy directory.
|
| And yes you can modify the *-ds.xml files using any text editor. That is the usual mechanism for editing those files (embedded jopr is new and previously all configuration was done by editing the config files directly using any text editor).
Sorry,you're right.
I was referring to the Admin-console.
If I change a datasource via the admin-console, it created a file in data / attachments without modifying the original, right? Therefore there is no way to synchronize the two files (one below and one under the deploy date / attachments)?
Last question: using JON, I have the same type of behavior?
Thanks
Bye
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4267071#4267071
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4267071
14 years, 11 months
[JBoss Cache Users] - Re: Question about lockParentForChildInsertRemove - when to
by bstansberry@jboss.com
Thanks for the question; I didn't personally work on the MVCC code and the discussions I'd been on didn't specifically discuss handling of children. So, had to chat with Jason Greene and look into the code, both of which are always good. :-)
As you said getChildren(Names) is a read operation, so with MVCC it won't block due to a concurrent write.
If you need to avoid phantom reads with getChildren(Names), i.e. do two reads in the same tx and not have children appear/disappear, you need to use lockParentForChildInsertRemove. REPEATABLE_READ is implemented by making a copy of the node before writing and storing it in a context object associated with the transaction, and then only inserting that copy into the main tree on tx commit. But the addition/removal of a child is only considered to be a "write" if lockParentForChildInsertRemove=true. If lockParentForChildInsertRemove=false, no copy of the parent is made, so the inserts/removals become visible to other threads as soon as they commit.
This behavior is consistent with the definition of REPEATABLE_READ in the java.sql.Connection javadocs, which says phantom reads can occur with R_R. Database notions never map exactly to a tree structure, but our interpretations have always treated new child nodes as being analogous to new db records returned by a query.
If you do set lockParentForChildInsertRemove=true, concurrent insertions/removals won't occur, but only one will proceed at a time; any others will block until the first completes.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4267068#4267068
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4267068
14 years, 11 months
[jBPM Users] - How to use timers?
by mauromol
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
14 years, 11 months
[jBPM Users] - Re: Violation of unique constraint with two splits (JBPM-255
by Alkero
Process:
<?xml version="1.0" encoding="UTF-8"?>
|
| <process name="TwoForks" xmlns="http://jbpm.org/4.0/jpdl">
| <start g="179,17,32,29" name="start1">
| <transition g="-43,-18" name="to fork1" to="fork1"/>
| </start>
| <fork g="185,95,49,50" name="fork1">
| <transition name="left" to="task1" g="-44,-18"/>
| <transition name="right" to="task2" g="-44,-18"/>
| </fork>
| <end g="193,606,38,33" name="end1"/>
| <task name="task1" g="90,177,73,44">
| <transition name="to fork2" to="fork2" g="-43,-18"/>
| </task>
| <task name="task2" g="249,172,83,48">
| <transition name="to join2" to="join2" g="288,425:-41,-18"/>
| </task>
| <task name="task3" g="21,313,88,45">
| <transition name="to join1" to="join1" g="-41,-18"/>
| </task>
| <task name="task4" g="154,313,88,48">
| <transition name="to join1" to="join1" g="-41,-18"/>
| </task>
| <fork name="fork2" g="108,250,37,28">
| <transition name="left" to="task3" g="-44,-18"/>
| <transition name="right" to="task4" g="-44,-18"/>
| </fork>
| <join name="join1" g="112,407,51,31">
| <transition name="to join2" to="join2" g="-41,-18"/>
| </join>
| <join name="join2" g="192,511,57,44">
| <transition name="to end1" to="end1" g="-42,-18"/>
| </join>
| </process>
Unit Test:
package org.jbpm.examples.fork;
|
| import java.util.Date;
| import java.util.List;
|
| import org.jbpm.api.ProcessInstance;
| import org.jbpm.api.task.Task;
| import org.jbpm.test.JbpmTestCase;
|
| import junit.framework.TestCase;
|
| public class TwoForksTest extends JbpmTestCase {
|
|
| String deploymentId;
|
| protected void setUp() throws Exception {
| super.setUp();
|
| deploymentId = repositoryService.createDeployment()
| .addResourceFromClasspath("org/jbpm/examples/fork/process.jpdl.xml")
| .deploy();
| }
|
| protected void tearDown() throws Exception {
| repositoryService.deleteDeploymentCascade(deploymentId);
|
| super.tearDown();
| }
|
| public void testTwoForks(){
| ProcessInstance processInstance = executionService.startProcessInstanceByKey("TwoForks");
| List<Task> tasks = taskService.createTaskQuery().list();
| for(Task task:tasks){
| taskService.completeTask(task.getId());
| }
| Date endTime = historyService
| .createHistoryProcessInstanceQuery()
| .processInstanceId(processInstance.getId())
| .uniqueResult()
| .getEndTime();
|
| assertNotNull(endTime);
| }
|
| }
|
Log:
16:07:07,015 SEV | [BaseJbpmTestCase] TEST THROWS EXCEPTION: could not update: [org.jbpm.pvm.internal.model.ExecutionImpl#14]
| org.hibernate.exception.ConstraintViolationException: could not update: [org.jbpm.pvm.internal.model.ExecutionImpl#14]
| at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94)
| at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
| at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2453)
| at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2335)
| at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2635)
| at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:115)
| at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
| at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
| at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
| at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
| at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
| at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
| at org.jbpm.pvm.internal.tx.HibernateSessionResource.prepare(HibernateSessionResource.java:56)
| at org.jbpm.pvm.internal.tx.StandardTransaction.commit(StandardTransaction.java:106)
| at org.jbpm.pvm.internal.tx.StandardTransaction.complete(StandardTransaction.java:65)
| at org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:61)
| 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.TaskServiceImpl.completeTask(TaskServiceImpl.java:88)
| at org.jbpm.examples.fork.TwoForksTest.testTwoForks(TwoForksTest.java:35)
| 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 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)
| Caused by: java.sql.SQLException: Violation of unique constraint $$: duplicate value(s) for column(s) $$: SYS_CT_9890 in statement [update JBPM4_EXECUTION set DBVERSION_=?, ACTIVITYNAME_=?, PROCDEFID_=?, HASVARS_=?, NAME_=?, KEY_=?, ID_=?, STATE_=?, SUSPHISTSTATE_=?, PRIORITY_=?, HISACTINST_=?, PARENT_=?, INSTANCE_=?, SUPEREXEC_=?, SUBPROCINST_=? where DBID_=? and DBVERSION_=?]
| at org.hsqldb.jdbc.Util.throwError(Unknown Source)
| at org.hsqldb.jdbc.jdbcPreparedStatement.executeUpdate(Unknown Source)
| at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2435)
| ... 38 more
Regards,
David
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4267063#4267063
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4267063
14 years, 11 months