AnsweredAssumed Answered

java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer when setting workflow priority

Question asked by douglascrp Moderator on Jan 31, 2015
Latest reply on Oct 16, 2017 by douglascrp

I'm facing with this weird behaviour trying to re-configure a running workflow's priority
java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer

My workflow is created with the default priority, medium.
On the first task user has the option to change the task.priority, and on the complete listener, I use this code to reflect the task's priority change to the workflow's priority:

execution.setVariable("bpm_workflowPriority", task.priority);

If I log the those variables' values, I see this:
task.priority = 1
bpm_workflowPriority = 1.0

If for any reason I try to execute that task again, and if the user changes the priority again, lets say, to 3, when I try to reflect the change back to the workflow, I get the error:
java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer

The reason I found is on the first execution, since the first value saved at the bpm_workflowPriority was 1.0, a double, when I try to set the new task.priority to it, 3, it fails trying to set the new integer value to the double variable.

This, for me, can be considered a bug, since I seems to be impossible to achieve what I need.

I'm running this test on Alfresco Community 4.2.f.

I've just raised a issue for this error with the same description at

One more info I've just found:
Looking at the database table, I see the register bellow, what confirms my suspect that the value is save as double, even though I set it using an integer

MariaDB [alfresco]> select * from ACT_RU_VARIABLE;
| ID_   | REV_ | TYPE_              | NAME_                      | EXECUTION_ID_ | PROC_INST_ID_ | TASK_ID_ | BYTEARRAY_ID_ | DOUBLE_ | LONG_         | TEXT_                                                        | TEXT2_ |
| 19678 |    1 | double             | bpm_workflowPriority       | 19601         | 19601         | NULL     | NULL          |       3 |          NULL | NULL                                                         | NULL   |

Thank you in advance.