3

We developped a SpringBoot project with Java 11 using optaplanner-core and defining rules in a Drools file. We have no issue for running the app in intelliJ with JDK.

We then deployed the app onto Azure app service where a JRE is installed. We get the following error:

Caused by: org.kie.memorycompiler.KieMemoryCompilerException: 
Cannot find the System's Java compiler. Please use JDK instead of JRE or add drools-ecj dependency to use in memory Eclipse compiler

We tried to add the following dependencies but we still get the same error:

<dependency>
    <groupId>org.optaplanner</groupId>
    <artifactId>optaplanner-core</artifactId>
    <version>8.4.1.Final</version>
</dependency>
<dependency>
    <groupId>org.drools</groupId>
    <artifactId>drools-ecj</artifactId>
    <version>7.51.0.Final</version>
</dependency>
<dependency>
    <groupId>org.eclipse.jdt</groupId>
    <artifactId>ecj</artifactId>
    <version>3.26.0</version>
</dependency>

Would anyone know how to solve this problem ?

Thank you

axellerdp
  • 31
  • 1

2 Answers2

3

Adding drools-ecj won't really fix this. The error message is misleading.

Using a JDK instead of a JRE. The easiest way is to upgrade to Java 11 (or higher), as that only comes with a JDK.

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120
  • Thank you for your answer but we are already using Java 11 on Azure app service and it is not possible to select any JDK. Are you saying that Optaplanner cannot run on a JRE ? Would the only alternative be to implement the `ConstraintProvider` interface and to drop drools files completely ? – axellerdp Jul 26 '21 at 12:51
  • 1
    There is no JRE anymore, Java 11 is simply not shipped as a JRE. If Azure removes `javac` from their Java distribution, then that needs to be discussed with them. I believe that Constraint Streams will require `javac` as well. Both CS and DRL result in Java source code being compiled at runtime. – Lukáš Petrovický Jul 26 '21 at 16:13
0

If running optaplanner with a JDK is no option for you, you can change the solver config to

<solver>
  <scoreDirectorFactory>
    <droolsAlphaNetworkCompilationEnabled>false</droolsAlphaNetworkCompilationEnabled>
  </scoreDirectorFactory>
</solver>

and if you're using unit tests for java constraints that use the ConstraintVerifier, instantiate it like this

new DefaultConstraintVerifier<>(new MyConstraints(), SolutionDescriptor.buildSolutionDescriptor(myModelClasses))
  .withDroolsAlphaNetworkCompilationEnabled(false)

However: From what I understood, disabling the drools alpha network compiler usually comes with a performance impact.

thimmwork
  • 1
  • 1