Our Quarkus/OptaPlanner application works fine in JVM mode, but when compiled to Native executable, it throws a exception at initialization. ..... native (powered by Quarkus 2.16.12.Final)
2023-12-20T15:18:32.848536120Z Caused by: java.lang.IllegalStateException: If there is no scoreDrl (null), scoreDrlFile (null) or constraintProviderClass (null) with DROOLS impl type (null), there can be no droolsAlphaNetworkCompilationEnabled (false) either.
at org.optaplanner.core.impl.score.director.ScoreDirectorFactoryFactory.validateNoDroolsAlphaNetworkCompilation(ScoreDirectorFactoryFactory.java:217)
2023-12-20T15:18:32.848550921Z at org.optaplanner.core.impl.score.director.ScoreDirectorFactoryFactory.decideMultipleScoreDirectorFactories(ScoreDirectorFactoryFactory.java:133)
at org.optaplanner.core.impl.score.director.ScoreDirectorFactoryFactory.buildScoreDirectorFactory(ScoreDirectorFactoryFactory.java:40)
at org.optaplanner.core.impl.solver.DefaultSolverFactory.buildScoreDirectorFactory(DefaultSolverFactory.java:166)
2023-12-20T15:18:32.848563806Z at org.optaplanner.core.impl.solver.DefaultSolverFactory.<init>(DefaultSolverFactory.java:71)
2023-12-20T15:18:32.848567567Z at org.optaplanner.core.api.solver.SolverFactory.create(SolverFactory.java:106)
2023-12-20T15:18:32.848570521Z at org.optaplanner.quarkus.bean.DefaultOptaPlannerBeanProvider.solverFactory(DefaultOptaPlannerBeanProvider.java:46)
at org.optaplanner.quarkus.bean.DefaultOptaPlannerBeanProvider_ProducerMethod_solverFactory_3b1fa4ff0a3de7781ba3e1239701086bba97ef14_Bean.create(Unknown Source)
We attempted to create a solverConfig.xml in our resources folder, setting our class, and register it as follows, but didn't help application.properties: quarkus.native.resources.includes=solverConfig.xml
<?xml version="1.0" encoding="UTF-8"?>
<solver xmlns="https://www.optaplanner.org/xsd/solver" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.optaplanner.org/xsd/solver https://www.optaplanner.org/xsd/solver/solver.xsd">
<scoreDirectorFactory>
<easyScoreCalculatorClass>com.blah.planner.OptimizationConstraintProvider</easyScoreCalculatorClass>
</scoreDirectorFactory>
<!-- Configure the optimization algorithms (optional) -->
<termination>
</termination>
<constructionHeuristic>
</constructionHeuristic>
<localSearch>
</localSearch>
</solver>
We are targeting Java 11 with a JDK17 compiler.
At this point we can attempt to convert to streams provider which does work with Native Compile in our other services, or attempt to upgrade to Quarkus 3.x. Any suggestions on if this configuration should work or if I need addition setup?
It is a bug in OptaPlanner, not in Quarkus. Timefold Solver doesn't suffer from this bug, but we no longer support the 0.8 version (which was fully compatible with OptaPlanner 8). The current version, Timefold Solver 1.5.0, is fully compatible with OptaPlanner 9 (and therefore Quarkus 3).
There are several options I see here:
One way to get rid of your problem is to switch to Constraint Streams. That way, you can continue using OptaPlanner 8. You shouldn't really be using Easy
in production anyway.
Switch to Timefold Solver 1.x (and Quarkus 3), which will allow you to use EasyScoreCalculator
in native mode. You will also benefit from many features, fixes and performance improvements not available in OptaPlanner.
Wait for if/when the OptaPlanner project fixes that issue.