Home > Net >  Optaplanner Error msg: "You're trying to use the Truth Maintenance System without having i
Optaplanner Error msg: "You're trying to use the Truth Maintenance System without having i

Time:10-26

I'm getting a new error msg on a Spring/Optaplanner app that has been running without incident that I don't understand:

edit: Optaplanner version is 8.19.0.Final Sprin boot: 2.2.7.RELEASE

You're trying to use the Truth Maintenance System without having imported it. Please add the module org.drools:drools-tms to your classpath.]

 Caused by: java.lang.IllegalStateException: There is an error in a scoreDrl or scoreDrlFile.
2022-10-24T20:49:11.164109 00:00 app[web.1]: at org.optaplanner.constraint.drl.AbstractDrlScoreDirectorFactoryService.buildScoreDirectorFactory(AbstractDrlScoreDirectorFactoryService.java:61)
 2022-10-24T20:49:11.164109 00:00 app[web.1]: at org.optaplanner.constraint.drl.DrlScoreDirectorFactoryService.lambda$buildScoreDirectorFactory$0(DrlScoreDirectorFactoryService.java:47)
2022-10-24T20:49:11.164109 00:00 app[web.1]: at org.optaplanner.core.impl.score.director.ScoreDirectorFactoryFactory.decideMultipleScoreDirectorFactories(ScoreDirectorFactoryFactory.java:137)
2022-10-24T20:49:11.164109 00:00 app[web.1]: at org.optaplanner.core.impl.score.director.ScoreDirectorFactoryFactory.buildScoreDirectorFactory(ScoreDirectorFactoryFactory.java:55)
2022-10-24T20:49:11.164110 00:00 app[web.1]: at org.optaplanner.core.impl.solver.DefaultSolverFactory.buildScoreDirectorFactory(DefaultSolverFactory.java:177)
2022-10-24T20:49:11.164110 00:00 app[web.1]: at org.optaplanner.core.impl.solver.DefaultSolverFactory.<init>(DefaultSolverFactory.java:87)
2022-10-24T20:49:11.164110 00:00 app[web.1]: at org.optaplanner.core.api.solver.SolverFactory.create(SolverFactory.java:122)
2022-10-24T20:49:11.164110 00:00 app[web.1]: at org.optaplanner.spring.boot.autoconfigure.OptaPlannerAutoConfiguration.solverFactory(OptaPlannerAutoConfiguration.java:115)
2022-10-24T20:49:11.164111 00:00 app[web.1]: at org.optaplanner.spring.boot.autoconfigure.OptaPlannerAutoConfiguration$$EnhancerBySpringCGLIB$$43d387fa.CGLIB$solverFactory$1(<generated>)
2022-10-24T20:49:11.164111 00:00 app[web.1]: at org.optaplanner.spring.boot.autoconfigure.OptaPlannerAutoConfiguration$$EnhancerBySpringCGLIB$$43d387fa$$FastClassBySpringCGLIB$$f1672db8.invoke(<generated>)
2022-10-24T20:49:11.164111 00:00 app[web.1]: at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
2022-10-24T20:49:11.164112 00:00 app[web.1]: at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
2022-10-24T20:49:11.164112 00:00 app[web.1]: at org.optaplanner.spring.boot.autoconfigure.OptaPlannerAutoConfiguration$$EnhancerBySpringCGLIB$$43d387fa.solverFactory(<generated>)
2022-10-24T20:49:11.164113 00:00 app[web.1]: at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2022-10-24T20:49:11.164113 00:00 app[web.1]: at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2022-10-24T20:49:11.164113 00:00 app[web.1]: at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2022-10-24T20:49:11.164113 00:00 app[web.1]: at java.base/java.lang.reflect.Method.invoke(Method.java:566)
2022-10-24T20:49:11.164114 00:00 app[web.1]: at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
2022-10-24T20:49:11.164114 00:00 app[web.1]: ... 53 common frames omitted
2022-10-24T20:49:11.164116 00:00 app[web.1]: Caused by: java.lang.RuntimeException: [Message [id=1, kieBase=defaultKieBase, level=ERROR, path=constraints.drl, line=-1, column=0
2022-10-24T20:49:11.164117 00:00 app[web.1]: text=You're trying to use the Truth Maintenance System without having imported it. Please add the module org.drools:drools-tms to your classpath.], Message [id=2, kieBase=defaultKieBase, level=ERROR, path=constraints.drl, line=-1, column=0
2022-10-24T20:49:11.164117 00:00 app[web.1]: text=You're trying to use the Truth Maintenance System without having imported it. Please add the module org.drools:drools-tms to your classpath.]]
2022-10-24T20:49:11.164118 00:00 app[web.1]: at org.kie.internal.utils.KieHelper.getKieContainer(KieHelper.java:106)

CodePudding user response:

I see you are using OptaPlanner's Score DRL support. drools-tms is a direct dependency of that module, as you will see when you run mvn dependency:tree on the OptaPlanner project. This error message is saying that, for some reason, the dependency is missing in your project.

I can not explain why the dependency is suddenly missing if it was there before, without you having done any changes. But there are two solutions to the issue:

  • Make sure the dependency is present on the runtime classpath of your application.
  • Switch to Constraint Streams, as score DRL has been deprecated for some time.
  • Related