Bug 854965 - Cannot retrieve Boolean variable from Human Task when using generated task form
Cannot retrieve Boolean variable from Human Task when using generated task form
Product: JBoss Enterprise BRMS Platform 5
Classification: JBoss
Component: jBPM 5 (Show other bugs)
BRMS 5.3.0.GA
Unspecified Unspecified
unspecified Severity high
: ER2
: BRMS 5.3.1 GA
Assigned To: Maciej Swiderski
Marek Baluch
Depends On:
  Show dependency treegraph
Reported: 2012-09-06 08:09 EDT by Jiri Svitak
Modified: 2015-06-01 21:39 EDT (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
An error occurred in the Business Central Console whenever parameters were transported as strings via HTTP protocol. They would not properly set as standard process variables such as Boolean, integer, float, and object. This would result in errors such as not being able to retrieve variables from the Human Task. This has been resolved by ensuring data type awareness for standard process variables, and it has been integrated with Business Central Console.
Story Points: ---
Clone Of:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
test case output (8.69 KB, text/plain)
2012-09-06 08:09 EDT, Jiri Svitak
no flags Details
test case (5.81 KB, application/x-zip-compressed)
2012-09-06 08:14 EDT, Jiri Svitak
no flags Details

External Trackers
Tracker ID Priority Status Summary Last Updated
JBoss Issue Tracker JBPM-3779 Major Resolved Cannot retrieve Boolean variable from Human Task when using generated task form 2016-06-22 08:03 EDT

  None (edit)
Description Jiri Svitak 2012-09-06 08:09:29 EDT
Created attachment 610286 [details]
test case output

Cannot retrieve Boolean variable from Human Task. I have a simple business process with one human task and one Boolean output. Task form generated in Designer creates a check box, but either checking it or leaving it unchecked I receive two different exceptions.

How to reproduce:
1. Download and run BRMS 5.3.0 GA patch 01 (I used standalone version with EAP5).
2. Configure your own user (in my case jsvitak) in your jboss-as. You cannot use admin, because this user doesn't work with human tasks (foreign key violation...admin is not the same as Administrator).
3. Download attached test case.
4. Open Designer and create a package named 'com.sample'. Upload to it business process definition file com.sample.boolean.bpmn2 from the test case. Change actor of the human task to your own user, that you created before. Generate task form and .png image for the process and save it.
5. Run attached maven based test case using the command:
mvn test -Dtest=HTHandlerBooleanTest
6. Log in to business-central (jbpm-console) by using the credentials of your newly created testing user.
7. You should see one task created by the test case and view it. You can check the check box and you'll receive
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean
or you can leave check box unchecked and you'll get NPE. To see the whole stack traces see attached log of the test case.

My environment:
BRMS 5.3.0 GA patch01 standalone
local HSQL database
Comment 1 Jiri Svitak 2012-09-06 08:14:43 EDT
Created attachment 610288 [details]
test case
Comment 2 Jiri Svitak 2012-09-07 05:26:31 EDT
The same problem occurs when retrieving an Integer process variable. It's from the server log, because the tested business process was launched from Jenkins web application deployed on EAP 5.

2012-09-07 11:19:29,429 ERROR [STDERR] (Thread-73) Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
2012-09-07 11:19:29,429 ERROR [STDERR] (Thread-73) 	at org.jenkinsci.plugins.jbpm.Process_org_jenkinsci_plugins_jbpm_example.returnValueEvaluator2(Unknown Source)
2012-09-07 11:19:29,429 ERROR [STDERR] (Thread-73) 	at org.jenkinsci.plugins.jbpm.Process_org_jenkinsci_plugins_jbpm_exampleReturnValueEvaluator2Invoker.evaluate(Unknown Source)
2012-09-07 11:19:29,429 ERROR [STDERR] (Thread-73) 	at org.jbpm.process.instance.impl.ReturnValueConstraintEvaluator.evaluate(ReturnValueConstraintEvaluator.java:128)
2012-09-07 11:19:29,429 ERROR [STDERR] (Thread-73) 	... 23 more
Comment 3 JBoss JIRA Server 2012-09-07 06:53:13 EDT
Maciej Swiderski <swiderski.maciej@gmail.com> updated the status of jira JBPM-3779 to Resolved
Comment 4 JBoss JIRA Server 2012-09-07 06:53:13 EDT
Maciej Swiderski <swiderski.maciej@gmail.com> made a comment on jira JBPM-3779

Problem is caused by mechanism that console uses to get information about parameters that are transmitted via HTTP. They are always of type String and that's why CCE is thrown. 
Fix that was applied makes use of DataType definitions to be able to build an object from it's string representation, following is the list of types that are currently supported:
- Boolean (java.lang.Boolean)
- Integer (java.lang.Integer)
- Float (java.lang.Float)
- Object (java.lang.Object)
- Object (custom class that can be recreated using XStream.fromXML())

When defining type of variable in bpmn2 use either short name, for example Boolean or fqcn java.lang.Boolean

Important to note is the way how boolean values must be taken care of when transmitting them from html form over HTTP, as they are usually represented as check box and browser will not send it at all when checkbox is not checked a special hidden input should be placed directly after it
<input type="checkbox" name="mycheckbox" value="true"/>
<input type="hidden" name="mycheckbox" value="false" />
Some sources recommends to put it before the actual checkbox input field but based on my tests it did not work properly in such configuration as it always replaced the selected value
Comment 5 Maciej Swiderski 2012-09-07 06:54:23 EDT
fix committed into master: https://github.com/droolsjbpm/jbpm/commit/cdd6782505b154cedacd8f589e9f8943d953726f
Comment 6 Maciej Swiderski 2012-09-11 06:14:06 EDT
merged into 5.2.x branch
Comment 7 Jiri Svitak 2012-09-14 04:16:48 EDT
The reproducer has been tested and it's not fixed in BRMS 5.3.1 ER1. I think it's because Maciej set the bug to MODIFIED when Julian was almost finished with the ER1 build, so probably this bug fix was not included.

Setting the state to MODIFIED, and I'll test it with ER2.
Comment 8 JBoss JIRA Server 2012-09-21 18:42:18 EDT
Sebastian Calbaza <calbazasebastian@yahoo.com> made a comment on jira JBPM-3779

There is an issue with the fix for this (cdd678250) when setting structureRef to "String" in the bpmn definition(ex.  <itemDefinition id="_vacaIdItem" structureRef="String" />)  and providing a String value in the result mapping.

Probably the fix for this issue is adding an if branch in org.jbpm.bpmn2.xml.PropertyHandler for String type.
Comment 9 Lukáš Petrovický 2012-09-24 04:17:04 EDT
Maciej, please see comment #8. Returning this back to ASSIGNED.
Comment 10 Maciej Swiderski 2012-09-24 12:00:30 EDT
Meged provided pull request (as part of JBPM-3800) and added additional tests to cover all supported data types.
Comment 11 Jiri Svitak 2012-10-04 11:38:29 EDT
Verified in BRMS 5.3.1 ER2.
Comment 12 Douglas Hoffman 2012-10-22 22:25:28 EDT
I have updated the information for the Release Notes. Thanks for all the comments regarding the fix.

- Doug

Note You need to log in before you can comment on or make changes to this bug.