Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 910780

Summary: "JbpmJUnitTestCase" is calling 'abortWorkItem' when task completes and thus it causes the 'task parameter' to 'process variable' mapping to fail
Product: [JBoss] JBoss Enterprise BRMS Platform 5 Reporter: Musharraf Hussain <mhussain>
Component: jBPM 5Assignee: Kris Verlaenen <kverlaen>
Status: CLOSED UPSTREAM QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: BRMS 5.3.0.GA   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2025-02-10 03:27:27 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
JbpmJUnitTestCase-Reproducer.zip none

Description Musharraf Hussain 2013-02-13 14:38:14 UTC
Description of problem:
We have a JUnit test class which extends "JbpmJUnitTestCase" where we are creating a TaskService like the following way:
~~~
  TaskService taskService = getTaskService(ksession); 
~~~
Everything goes well with claiming and starting the task like this:
~~~
  taskService.claim(task.getId(), "xxx",  groupIds);
  taskService.start(task.getId(), "xxx");
~~~
But after that we have observed that the 'task parameter' to 'process variable' mapping seems to be failing which results in NPE. Debugging the issue reveals that it is calling 'abortWorkItem' when the task completes, which causes the 'task parameter' to 'process variable' mapping to fail.

Looking at the source code of "JbpmJUnitTestCase" you can observe two "LocalTaskService" instances in "getTaskService(...)" method.
~~~
SyncWSHumanTaskHandler humanTaskHandler = new SyncWSHumanTaskHandler(
			new LocalTaskService(taskServiceSession), ksession);
...
return new LocalTaskService(taskServiceSession);
~~~

As a workaround we have checked that if we are sharing the same instance of "LocalTaskService" between "SyncWSHumanTaskHandler" and client application then it works fine.
~~~
 LocalTaskService localTaskService = new LocalTaskService(getService());

        SyncWSHumanTaskHandler humanTaskHandler = new SyncWSHumanTaskHandler(
                localTaskService, ksession);
        ...
        return localTaskService;
~~~

[1] https://github.com/mswiderski/jbpm/blob/5.2.0.Final/jbpm-test/src/main/java/org/jbpm/test/JbpmJUnitTestCase.java

Version-Release number of selected component (if applicable):
- jBPM 5.2 shipped with JBoss Enterprise BRMS Platform 5.3.0

How reproducible:
- Use the attached "JbpmJUnitTestCase-Reproducer.zip" test case which has been built on JBDS to reproduce the issue.

Steps to Reproduce:
1. Import the attached "JbpmJUnitTestCase-Reproducer.zip" JUnit test case on JBDS as a Project.
2. Run the "TestingProcess_BUG" class as a "JUnit Test" to reproduce the issue
3. Just to test the suggested workaround you can Run the "TestingProcess_SUCCESS" class as a "JUnit Test" to confirm if it works fine.
  
Actual results:
- Running the "TestingProcess_BUG" class causes an NPE.
- While running the "TestingProcess_SUCCESS" class just works fine as expected.

Expected results:
- Ideally, running the "TestingProcess_BUG" class shouldn't cause the NPE.

Additional info:

Comment 2 Musharraf Hussain 2013-02-14 10:02:05 UTC
Hello,

I just want to update the URL for the "JbpmJUnitTestCase.java" source code which I mentioned in my first comment, since 'droolsjbpm' is the correct repository. Please ignore it and use the new one which I mentioned here.

FROM
-----
https://github.com/mswiderski/jbpm/blob/5.2.0.Final/jbpm-test/src/main/java/org/jbpm/test/JbpmJUnitTestCase.java

TO
---
https://github.com/droolsjbpm/jbpm/blob/5.2.0.Final/jbpm-test/src/main/java/org/jbpm/test/JbpmJUnitTestCase.java


Also, thanks to Toshiya-san for this discovery as it seems to be fixed in master [1].
~~~
    public TaskService getTaskService(StatefulKnowledgeSession ksession) {
     if (taskService == null) {
     taskService = new org.jbpm.task.service.TaskService(
emf, SystemEventListenerFactory.getSystemEventListener());
    
     UserGroupCallbackManager.getInstance().setCallback(new DefaultUserGroupCallbackImpl("classpath:/usergroups.properties"));
     }
     LocalTaskService localTaskService = new LocalTaskService(taskService);
LocalHTWorkItemHandler humanTaskHandler = new LocalHTWorkItemHandler(
localTaskService, ksession, OnErrorAction.RETHROW);
humanTaskHandler.connect();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", humanTaskHandler);
return localTaskService;
    }
~~~

[1] https://github.com/droolsjbpm/jbpm/blob/master/jbpm-test/src/main/java/org/jbpm/test/JbpmJUnitTestCase.java


Regards,
Musharraf Hussain

Comment 4 Red Hat Bugzilla 2025-02-10 03:27:27 UTC
This product has been discontinued or is no longer tracked in Red Hat Bugzilla.