Search code examples
optaplannerkie

Conflict kie-server-client and optaplanner-spring-boot-starter


When I use between dependencies together

<dependency>
  <groupId>org.kie.server</groupId>
  <artifactId>kie-server-client</artifactId>
</dependency>

<dependency>
  <groupId>org.optaplanner</groupId>
  <artifactId>optaplanner-spring-boot-starter</artifactId>
</dependency>

I get below warn

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'solverManager' defined in class path resource [org/optaplanner/spring/boot/autoconfigure/OptaPlannerAutoConfiguration.class]: Unsatisfied dependency expressed through method 'solverManager' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'solverFactory' defined in class path resource [org/optaplanner/spring/boot/autoconfigure/OptaPlannerAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.optaplanner.core.api.solver.SolverFactory]: Factory method 'solverFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: org/drools/core/reteoo/CoreComponentFactory

and then an exception.

Do you know how I can use these two dependencies together?


Solution

  • OptaPlanner 8 and Drools 7 can not be used together. OptaPlanner 8 relies on Drools 8, and that will cause all sorts of classpath conflicts.

    There is a way how to use OptaPlanner 8 without Drools. Assuming you do not use score DRL (or, if you're using constraint streams, you switch to the BAVET implementation) you will be able to remove all Drools dependencies from OptaPlanner 8. However, I can not guarantee that this will not blow up for some other reason, as it's never been tried; the safest answer is that this is just not going to work. OptaPlanner 8 requires Drools 8.

    Another option is to use OptaPlanner 7 which has been designed to work with KIE, but that (very old) version is no longer maintained by the community.