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

Bug 1062859

Summary: NPE in GetTaskContentCommand.java:37 when trying to get task content for second human task in own web app
Product: [Retired] JBoss BPMS Platform 6 Reporter: Jiri Svitak <jsvitak>
Component: jBPM CoreAssignee: Maciej Swiderski <mswiders>
Status: CLOSED CURRENTRELEASE QA Contact: Jiri Svitak <jsvitak>
Severity: low Docs Contact:
Priority: high    
Version: 6.0.0CC: mbaluch, rrajasek
Target Milestone: ER2   
Target Release: 6.0.1   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-08-06 20:03:26 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
server.log
none
rewards-1.0.jar none

Description Jiri Svitak 2014-02-08 09:37:01 UTC
Created attachment 860854 [details]
server.log

NPE in GetTaskContentCommand.java:37 when trying to get task content for second human task.

Caused by: java.lang.NullPointerException
	at org.jbpm.services.task.commands.GetTaskContentCommand.execute(GetTaskContentCommand.java:37) [jbpm-human-task-core-6.0.2-redhat-2.jar:6.0.2-redhat-2]

To reproduce:
1.) Download and start JBoss EAP 6.1.1 (no configuration necessary)
2.) Install the attached artifact .jar to your local maven repo.
3.) Download, build and deploy app:
git clone https://github.com/jsvitak/jbpm-6-examples.git
git checkout product
cd jbpm-6-examples/rewards-jsf
mvn clean package
mvn jboss-as:deploy
4.) Go to localhost:8080/rewards-jsf, start process, complete task for user john, click to open aprrove task dialog for user mary and exception occurs.

This should work, or at least no NPE should be thrown. I am going to investigate other databases later. It's curious that first task works (both input and output params are correctly passing data), but the second fails to load. When I omit filling the output parameter map, both tasks are loaded and completed well. The same process works in business central well, so the issue might be connected to tx management in web app.

My env:
JBoss EAP 6.1.1
BPMS library version in web app 6.0.2-redhat-2 (CR2)
H2 database (will investigate later with other databases)

Comment 1 Jiri Svitak 2014-02-08 09:39:03 UTC
Created attachment 860855 [details]
rewards-1.0.jar

Install this artifact to your local .m2 repo

Comment 2 Jiri Svitak 2014-02-08 11:14:33 UTC
Additional info:
The task can be normally completed after the NPE, and it passes output data (filled from user-defined form) correctly to process variables.

Comment 3 Maciej Swiderski 2014-02-09 15:36:05 UTC
Jiri,

the problem is that you should use task id and not documentContentId when calling getTaskContent method: https://github.com/jsvitak/jbpm-6-examples/blob/master/rewards-jsf/src/main/java/org/jbpm/examples/ejb/TaskBean.java#L97

so it might work for the first or some execution when taskId and documentContentId will somehow match but it's very dangerous as you might end up having incorrect information - taken from other task than you expect.

Comment 4 Maciej Swiderski 2014-02-12 14:56:41 UTC
added check if task was found to avoid NPE and produce meaningful exception

jbpm
master:
https://github.com/droolsjbpm/jbpm/commit/880b099f9448d3bf11a2e2b25322d500d093624e

6.0x:
https://github.com/droolsjbpm/jbpm/commit/49448fe2830b5440351e4f2a87135935ecdae6b6

Comment 5 Jiri Svitak 2014-02-13 14:44:27 UTC
Thanks Maciej for explanation. You are correct, I have changed my code and now it works well. You've still fixed the NPE, so I'll verify this BZ later. 

NPE was just a result of a bad API usage, so I am lowering the severity.

Comment 6 Jiri Svitak 2014-03-04 11:48:37 UTC
Verified in BPMS 6.0.1.ER2.

Comment 7 Jiri Svitak 2014-03-18 10:04:16 UTC
NPEs are not serious, so no regression test required.