-
Bug
-
Resolution: Done
-
Major
-
None
-
None
-
None
-
2021 Week 04-06 (from Jan 25), 2021 Week 07-09 (from Feb 15)
-
1
-
Undefined
-
NEW
-
NEW
In the task-assigning model we have the following variable listener:
public class StartAndEndTimeUpdatingVariableListener implements VariableListener<TaskAssigningSolution, TaskAssignment> { public StartAndEndTimeUpdatingVariableListener() { } //bla bla bla }
The listener above works well in a quarkus service implemented by using the optaplanner-quarkus extension and the task-assigning model.
For example, it's possible to inject the SolverFactory<TaskAssigningSolution> in a service class, create solver instances etc.
However, when we build the native image for the same service and execute it, at runtime we get the following error:
2021-01-20 18:15:12,054 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-1) HTTP Request to /task-assigning/executeSolver failed, error id: 1b4402be-f6fa-48af-997e-b4c05de64a2e-1: org.jboss.resteasy.spi.UnhandledException: java.lang.IllegalArgumentException: The CustomShadowVariableDescriptor's variableListenerClass (org.kie.kogito.taskassigning.core.model.solver.StartAndEndTimeUpdatingVariableListener) does not have a public no-arg constructor.
at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:106)
at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:372)
Which basically complains about a "missing no-arg constructor", however the constructor exists.
NOW, if we decorate the listener above with the @RegisterForRelection annotation and repeat the build procedure, etc, the native image will work.
@RegisterForReflection public class StartAndEndTimeUpdatingVariableListener implements VariableListener<TaskAssigningSolution, TaskAssignment> { public StartAndEndTimeUpdatingVariableListener() { // required for native execution. } bla bla bla }
The conclusion is that the VariableListener are not being picked up and properly processed by the optaplanner-quarkus extension.
The workaround is to decorate the variable listener with the @RegisterForReflection annotation.
- is related to
-
PLANNER-2183 Kogito Continuous Task Assignment in jBPM using OptaPlanner
- Resolved