[jBPM Users] - Re: workflow design about wait states
by jbarrez
The issue here is that you have multiple threads, the JUnit thread and the JobExecutor thread(s).
The process is started in the JUnit thread until the custom activities in the fork are encountered. Jobs are created and put in the database.
These jobs will be picked up by the JobExecutor threads somewhere in the future. However, the JUnit thread is still running and reaches the end of the method call. The JUnit framework will now kill its ThreadRunner, which also kills all spawned processes (Jobexecutor threads).
The join activity can never ensure here that all threads have finished, for the simple reason that the join is potentially never even reached (if the JUnit thread finished quickly).
If you want to control your unit test, you must disable the job executor in your config and fire the jobs yourself.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4255329#4255329
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4255329
16 years, 7 months
[jBPM Users] - Re: workflow design about wait states
by mmusaji
For completion purposes I'll post my unittest and processdefinition again:
My unit test with changes suggested.
| package org.workflow.test.forum;
|
| import java.util.List;
| import java.util.Map;
|
| import org.jbpm.api.Execution;
| import org.jbpm.api.ProcessInstance;
| import org.jbpm.api.activity.ActivityBehaviour;
| import org.jbpm.api.activity.ActivityExecution;
| import org.jbpm.api.activity.ExternalActivityBehaviour;
| import org.jbpm.api.job.Job;
| import org.jbpm.test.JbpmTestCase;
|
| public class ProcessTest extends JbpmTestCase {
| String deploymentDbid;
|
| protected void setUp() throws Exception {
| super.setUp();
| deploymentDbid = repositoryService.createDeployment()
| .addResourceFromClasspath("org/workflow/test/forum/process.jpdl.xml")
| .deploy();
| }
|
| protected void tearDown() throws Exception {
| repositoryService.deleteDeploymentCascade(deploymentDbid);
| super.tearDown();
| }
|
| public void testProcess() {
| ProcessInstance processInstance = executionService.startProcessInstanceByKey("process");
| Execution executionInOne = processInstance.findActiveExecutionIn("custom one");
| assertNotNull(executionInOne);
| processInstance = executionService.signalExecutionById(executionInOne.getId());
|
| String processInstanceId = processInstance.getId();
|
| List<Job> jobs = managementService.createJobQuery()
| .processInstanceId(processInstanceId)
| .list();
|
| assertEquals("Job size doesn't equal 2",2, jobs.size());
|
| Job job = jobs.get(0);
|
| managementService.executeJob(job.getId());
|
| job = jobs.get(1);
|
| managementService.executeJob(job.getId());
|
| processInstance = executionService.findProcessInstanceById(processInstanceId);
|
| Execution executionInFour = processInstance.findActiveExecutionIn("custom four");
| assertNotNull("ExecutionInFour Is Null",executionInFour);
| processInstance = executionService.signalExecutionById(executionInFour.getId());
|
|
| if(executionService.findProcessInstanceById(processInstanceId) != null) {
| assertFalse("ProcessInstance.isEnded() is not false",processInstance.isEnded());
| }else {
| assertNull("processInstanceID not null",executionService.findProcessInstanceById(processInstanceId));
| }
|
| }
|
| public static class CustomOne implements ExternalActivityBehaviour {
| private static final long serialVersionUID = 1L;
|
| public void execute(ActivityExecution execution) throws Exception {
| System.out.println("Executing");
|
| System.out.println(execution.getActivityName());
|
| execution.waitForSignal();
| }
|
| public void signal(ActivityExecution execution,
| String signalName,
| Map<String, ?> parameters) {
| execution.take(signalName);
| }
| }
|
| public static class CustomTwo implements ActivityBehaviour {
| private static final long serialVersionUID = 1L;
|
| public void execute(ActivityExecution execution) throws Exception {
| System.out.println("Executing");
|
| System.out.println(execution.getActivityName());
|
| execution.takeDefaultTransition();
| }
|
| public void signal(ActivityExecution execution,
| String signalName,
| Map<String, ?> parameters) {
| execution.take(signalName);
| }
| }
|
| public static class CustomThree implements ActivityBehaviour {
| private static final long serialVersionUID = 1L;
|
| public void execute(ActivityExecution execution) throws Exception {
| System.out.println("Executing");
|
| System.out.println(execution.getActivityName());
|
| execution.takeDefaultTransition();
| }
|
| public void signal(ActivityExecution execution,
| String signalName,
| Map<String, ?> parameters) {
| execution.take(signalName);
| }
| }
|
| public static class CustomFour implements ExternalActivityBehaviour {
| private static final long serialVersionUID = 1L;
|
| public void execute(ActivityExecution execution) throws Exception {
| System.out.println("Executing");
|
| System.out.println(execution.getActivityName());
|
| execution.waitForSignal();
| }
|
| public void signal(ActivityExecution execution,
| String signalName,
| Map<String, ?> parameters) {
| execution.take(signalName);
| }
| }
|
| }
|
|
Workflow
| <?xml version="1.0" encoding="UTF-8"?>
|
| <process name="process" xmlns="http://jbpm.org/4.0/jpdl">
| <start>
| <transition to="custom one"/>
| </start>
|
| <custom class="org.workflow.test.forum.ProcessTest$CustomOne" name="custom one">
| <transition to="fork"/>
| </custom>
|
| <fork name="fork">
| <transition name="custom two" to="custom two"/>
| <transition name="custom three" to="custom three"/>
| </fork>
|
| <custom continue="async" name="custom two" class="org.workflow.test.forum.ProcessTest$CustomTwo">
| <transition to="join"/>
| </custom>
|
| <custom continue="async" name="custom three" class="org.workflow.test.forum.ProcessTest$CustomThree">
| <transition to="join"/>
| </custom>
|
| <join name="join" continue="exclusive" >
| <transition name="custom four" to="custom four"/>
| </join>
|
| <custom name="custom four" class="org.workflow.test.forum.ProcessTest$CustomFour">
| <transition to="end"/>
| </custom>
|
| <task name="end">
| <transition name="to complete" to="end process"/>
| </task>
|
| <end name="end process" state="complete"/>
|
| </process>
|
Sometimes this runs to completion and sometimes it fails. Its very similiar to the issue I had when the unit test thread was completing ahead of the workflow. I suspect putting a small sleep in there will fix this but this is what I (we) are trying to fix. The join should ensure is only continues once all have joined from the fork.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4255324#4255324
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4255324
16 years, 7 months
[JBoss Tools Users] - Re: Web App Libraries not published?
by deanhiller
well, I finally got it to work in jboss tools kind of, but I sure could not mount my project from jboss tools. Here is the exact play by play
First, my dir structure
project
---input
------javasrc
------libexclude - jars not to be put in WEB-INF/lib
------libinclude -- jars to be put in WEB-INF/lib
------webroot - xhtml files and jpgs, etc
---------WEB-INF - descriptors (NO jars, no class files)
In WTP, I finally managed to mount this project doing the following
1. checkout project from CVS (then find out there is no way to convert to JSF like JBoss has, but alas, I tried that way in JBoss and it didn't work)
2. then delete project but leave on filesystem
3. delete .project and .classpath files to make sure it is a clean java project with no eclipse relationship
NOW, I figure I can mount using dynamic web project so I do that
4. choose new->dynamic web project
5. Use default must stay checked and you HAVE to make sure the path maps to where your project is. If you uncheck it and pick your project, it gives you a weird error saying project already exists but if you leave it checked, it is fine with your project being there which is odd.
(I tried these same exact steps with jboss as well by the way)
6. Next step was then to choose the properties->J2EE Module Dependencies and add all the jars there
7. NExt add a tomcat runtime to the servers tab and deploy
deploying worked great in WTP. Following all these same steps in JBoss, deployment failed with ClassNotFoundExceptions like Web App Libraries were not being deployed or something
Workaround....to work around this, you HAVE to mount the java project while eclipse is WTP and then install JBoss tools AFTER you have mounted the project and deployment to tomcat works. then, for some reason, JBoss tools is ok.
Another really really annoying thing is when I add the seam facet, it adds jars to input/webroot/WEB-INF/lib folder which is very annoying..our jars are in libinclude and all generated content we put in output folder so just deleting the output folder is enough to clean a project. At some point, jboss tools had put classes in input/webroot/WEB-INF/classes as well even though our output folder is eclipsegen folder.
I hope this helps. I spent 3 days on this.
Oh, and my personal opinion is that the wizards should really really ask for 4 or 5 things
1. javasrc
2. where jars are for WEB-INF/lib
3. where jars are for libexclude(and this is where runtime jars should be put so project can build without external dependencies if user wants)
4. where root of web files are
5. maybe an output folder if jboss tools really needs to write out classes, jars into WEB-INF(and then just copy over webroot) sort of like the eclipse output folder for classes......it is configurable.
Lastly, in JSF WTP, you can choose self manage jars(this is a GREAT feature allowing lots of flexibility)...when adding Seam, it does not let you do that, there is no option.
I hope this helps some, thanks for the work!!!
Dean
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4255318#4255318
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4255318
16 years, 7 months