我在 Netbeans 8 上构建的 Java 程序(在本例中是 Optaplanner 的变体)中有一个 Drools 文件。运行该程序时,我收到一条错误消息:
Exception in thread "main" java.lang.IllegalArgumentException: The scoreDrl (taskassignment/solver/taskAssignmentScoreRules.drl) does not exist as a classpath resource.
at org.optaplanner.core.config.score.director.ScoreDirectorFactoryConfig.buildKieBase(ScoreDirectorFactoryConfig.java:304)
at org.optaplanner.core.config.score.director.ScoreDirectorFactoryConfig.buildDroolsScoreDirectorFactory(ScoreDirectorFactoryConfig.java:279)
at org.optaplanner.core.config.score.director.ScoreDirectorFactoryConfig.buildScoreDirectorFactory(ScoreDirectorFactoryConfig.java:186)
at org.optaplanner.core.config.score.director.ScoreDirectorFactoryConfig.buildScoreDirectorFactory(ScoreDirectorFactoryConfig.java:174)
at org.optaplanner.core.config.solver.SolverConfig.buildSolver(SolverConfig.java:145)
at org.optaplanner.core.config.solver.XmlSolverFactory.buildSolver(XmlSolverFactory.java:101)
at taskassignment.app.TaskAssignmentHelloWorld.main(TaskAssignmentHelloWorld.java:32)
does not exist as a classpath resource
在谷歌上搜索了错误消息后,当 drools 代码中出现错误时,它似乎是从 Optaplanner 抛出的。
我的问题是,没有关于 drools 文件中错误位置的更多信息,调试这段代码的好方法是什么?是否有任何插件可以帮助我缩小问题的范围,就像 Netbeans 通常使用 Java 一样?
这是我的 Drools 代码,可以很好地衡量:
package taskassignment.solver;
dialect "java"
import org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScoreHolder;
import taskassignment.domain.TaskAssignment;
import taskassignment.domain.Task;
import taskassignment.domain.Dev;
global HardSoftScoreHolder scoreHolder;
// ############################################################################
// Hard constraints
// ############################################################################
rule "DevCanOnlyDoOneTask"
when
$T1:Task
$T2:Task
$D:Dev
(($T1.getAssignedDev()=$D)&&($T2.getAssignedDev()=$D)&&(($T2.getAllottedStartTime()<=$T1.getAllottedStartTime())&&($T1.getAllottedStartTime()<$T2.getAllottedStartTime()+$T2.getDuration()))||(($T1.getAllottedStartTime()<=$T2.getAllottedStartTime())&&($T2.getAllottedStartTime()<$T1.getAllottedStartTime()+$T1.getDuration()))
then
scoreHolder.addHardConstraintMatch(kcontext,-1000);
end
// ############################################################################
// Soft constraints
// ############################################################################
rule "MaximiseEarliestFinishTime"
when
$TA: TaskAssignment
$EFT: $TA.getEFT()
then
scoreHolder.addSoftConstraintMatch(kcontext,+$EFT);
多谢你们