cancel
Showing results for 
Search instead for 
Did you mean: 

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

douglascrp
World-Class Innovator
World-Class Innovator
Hey.

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 https://issues.alfresco.com/jira/browse/ALF-21252

EDIT:
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.
1 ACCEPTED ANSWER

This is the way I did it:

I made a global variable (e.g. customPriority) and in each task I am setting this one, not the bpm_workflowPriority. Then I read it and set the task.priority. So the workflow priority stays the same, but I change each task priority according to the customPriority value.

Not the best way to do it, but it works for me...

View answer in original post

7 REPLIES 7

softwareloop
Champ in-the-making
Champ in-the-making
Can you post a bit more of the stacktrace?

douglascrp
World-Class Innovator
World-Class Innovator
There is nothing logged. I only see that message on Share.

java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer

I could only discover those integer and double values by writing some logs by myself using logger.log()

hackerkok
Champ on-the-rise
Champ on-the-rise

 Hello there!

I am facing the same issue with the bpm_workflowPriority. Did you manage to solve it?

Thanks in advance

douglascrp
World-Class Innovator
World-Class Innovator

Hello.

No, that got never fixed, and I simply gave up on doing that.

Too bad...

Thanks for the fast reply. I ll post here if I find anything

This is the way I did it:

I made a global variable (e.g. customPriority) and in each task I am setting this one, not the bpm_workflowPriority. Then I read it and set the task.priority. So the workflow priority stays the same, but I change each task priority according to the customPriority value.

Not the best way to do it, but it works for me...

douglascrp
World-Class Innovator
World-Class Innovator

I am glad you got it working.