optaplanner / drools workbench 6.4.0 Final ScoreDirectorFacotry

optaplanner / drools workbench 6.4.0 Final ScoreDirectorFacotry

我正在尝试使用 Drools Workbench 6.4.0 Final 版在 KIE 服务器中重新创建 CloudBalancing 示例。我可以通过 REST API 在 KIE 中创建容器和求解器,但是当我尝试开始求解时出现以下错误:

03:15:50,831 INFO  [org.kie.server.services.impl.KieServerImpl] (EJB default - 2) Container optacloud_1_0_0 (for release id opta:optacloud:1.0.0) successfully started
03:17:44,170 INFO  [org.kie.server.services.optaplanner.SolverServiceBase] (default task-13) Solver 'solver1' successfully created in container 'optacloud_1_0_0'
03:19:19,654 ERROR [org.kie.server.services.optaplanner.SolverServiceBase] (pool-9-thread-1) Exception executing solver 'solver1' from container 'optacloud_1_0_0'. Thread will terminate.: java.lang.NullPointerException
    at java.util.concurrent.ConcurrentHashMap.hash(ConcurrentHashMap.java:333) [rt.jar:1.7.0_80]
    at java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:1125) [rt.jar:1.7.0_80]
    at org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:613) [drools-compiler-6.4.0.Final.jar:6.4.0.Final]
    at org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:575) [drools-compiler-6.4.0.Final.jar:6.4.0.Final]
    at org.optaplanner.core.impl.score.director.drools.DroolsScoreDirectorFactory.newKieSession(DroolsScoreDirectorFactory.java:113) [optaplanner-core-6.4.0.Final.jar:6.4.0.Final]
    at org.optaplanner.core.impl.score.director.drools.DroolsScoreDirector.resetKieSession(DroolsScoreDirector.java:68) [optaplanner-core-6.4.0.Final.jar:6.4.0.Final]
    at org.optaplanner.core.impl.score.director.drools.DroolsScoreDirector.setWorkingSolution(DroolsScoreDirector.java:61) [optaplanner-core-6.4.0.Final.jar:6.4.0.Final]
    at org.optaplanner.core.impl.solver.scope.DefaultSolverScope.setWorkingSolutionFromBestSolution(DefaultSolverScope.java:198) [optaplanner-core-6.4.0.Final.jar:6.4.0.Final]
    at org.optaplanner.core.impl.solver.DefaultSolver.solvingStarted(DefaultSolver.java:196) [optaplanner-core-6.4.0.Final.jar:6.4.0.Final]
    at org.optaplanner.core.impl.solver.DefaultSolver.solve(DefaultSolver.java:175) [optaplanner-core-6.4.0.Final.jar:6.4.0.Final]
    at org.kie.server.services.optaplanner.SolverServiceBase.run(SolverServiceBase.java:329) [kie-server-services-optaplanner-6.4.0.Final.jar:6.4.0.Final]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_80]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_80]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_80]

是否因为我在 SolverConfig.xml 中缺少 'scoreDrl'?如何通过 workbench UI 配置 SolverConfig.xml ?看来我无法通过界面编辑 SolverConfig.xml。

感谢 Geoffrey 的调查,他发现问题的根本原因与 DROOLS-1276 有关。该问题的解决方法是不使用默认的 ksession。

在 Drools workbench 中创建会话如下:

Project Authoring ->  Open Project Editor -> Knowledge Bases and Sessions

然后更新项目Solver配置中的Knowledge Session。问题将得到解决。