We upgraded from 7.14 to 7.19 and I think we have a GraalVm upgrade issue in a Javascript Service Task. Code snippet:
var currentDay = new java.util.Date();
currentDay.setHours(0);
currentDay.setMinutes(0);
currentDay.setSeconds(0);
// Get latest all finished instances for current day only
var list = managementService.createJobQuery()
.processDefinitionKey("ProcessStuff")
.duedateHigherThenOrEquals(currentDay)
.orderByJobDuedate()
.desc()
.list();
if (list.length !== 0) {
var stuff = list[0];
shouldUpload = checkIfDue(stuff.duedate); // Problem: duedate not defined
}
In 7.14, we did get the duedata of the “ProcessStuff” process, but not so in 7.19 (the “checkIfDue” function reports that the passed argument is undefined).
Also: we used java.util.logging.Logger for some basic debugging in Nashorn, is there a replacement in GraalVm?
The java version is:
openjdk 11.0.18 2023-01-17
OpenJDK Runtime Environment (build 11.0.18+10-alpine-r0)
OpenJDK 64-Bit Server VM (build 11.0.18+10-alpine-r0, mixed mode)
Yes, I guess it stopped working with GraalVm. However, the update notes are not helpful for my problem.
I wish I knew how to print some debug statements somewhere somehow, at least.
I am using “duedateHigherThan” now, but that does not seem to fix the problem. In Nashorn, we used java.util.logging.Logger for logging - what would I use in GraalVm (or is there a better way to dump some values)?
Unfortunately, I don’t know GraalVM at all, so I can’t tell you. I would think you should be able to use some sort of print statement to dump your variables to string.
Thank you once again for the good pointers. I fixed this by:
Replacing all java.util. usages, we used Logging and Date, I am using the Javacript Date type now and simply console.log() to get a message into the camunda log
Replacing .duedateHigherThenOrEquals(currentDay) with .duedateHigherThan
Using accessors instead of fields, e.g. stuff.duedate did not work anymore but stuff.getDuedate() does. It returns a unix date that I can convert to js date with “new Date(stuff.getDuedate())”.
Sidenote: when passing the duedate to another process, it needs to be converted to a unix timestamp again, e.g. “execution.setVariable(“duedate”, Math.floor(duedate.getTime() / 1000));”