Drools Planner在创建配置程序时遇到问题:如何调试

时间:2012-01-27 10:33:47

标签: drools drools-planner

我尝试从XML配置创建解算器。但整个过程会返回一个毫无意义的神秘错误消息。

我该如何解决这个问题?我怎样才能理解这一点来实际解决类似的问题呢?

jesvin@Jesvin-Technovia:~/dev/drools/sudoku$ java App 
Exception in thread "main" java.lang.NullPointerException
    at org.drools.planner.core.domain.solution.SolutionDescriptor.processPropertyAnnotations(SolutionDescriptor.java:69)
    at org.drools.planner.core.domain.solution.SolutionDescriptor.<init>(SolutionDescriptor.java:61)
    at org.drools.planner.config.solver.SolverConfig.buildSolutionDescriptor(SolverConfig.java:197)
    at org.drools.planner.config.solver.SolverConfig.buildSolver(SolverConfig.java:167)
    at org.drools.planner.config.XmlSolverConfigurer.buildSolver(XmlSolverConfigurer.java:103)
    at App.createSolver(App.java:62)
    at App.main(App.java:40)

此处列出了抛出它的函数。该行当然是return configurer.buildSolver();

private static Solver createSolver(){
XmlSolverConfigurer configurer = new XmlSolverConfigurer();
File file = new File("solver.xml");
FileInputStream fin = null;
try{
    fin = new FileInputStream(file);    
}
catch(IOException e){
     System.out.println("Unable to read drl");
}
configurer.configure(fin);
    //configurer.configure("/home/jesvin/dev/drools/sudoku/solver.xml");
    return configurer.buildSolver();
}

XML的内容:

<?xml version="1.0" encoding="UTF-8"?>
<solver>
  <environmentMode>DEBUG</environmentMode>

  <solutionClass>domain.Sudoku</solutionClass>
  <planningEntityClass>domain.Digit</planningEntityClass>
  <scoreDrl>score.drl</scoreDrl>
  <scoreDefinition>
    <scoreDefinitionType>SIMPLE</scoreDefinitionType>
  </scoreDefinition>

  <termination>
    <scoreAttained>0</scoreAttained>
  </termination>
  <!--
  <constructionHeuristic>
    <constructionHeuristicType>FIRST_FIT_DECREASING</constructionHeuristicType>
    <constructionHeuristicPickEarlyType>FIRST_LAST_STEP_SCORE_EQUAL_OR_IMPROVING</constructionHeuristicPickEarlyType>
</constructionHeuristic> -->
  <constructionHeuristic>
    <constructionHeuristicType>FIRST_FIT</constructionHeuristicType>

      <moveFactoryClass>solution.RowChangeMoveFactory</moveFactoryClass>
    </selector>
    <acceptor>
      <completeSolutionTabuSize>1000</completeSolutionTabuSize>
    </acceptor>
    <forager>
      <!-- Real world problems require to use of <minimalAcceptedSelection> -->
    </forager>
  </localSearch>
</solver>

2 个答案:

答案 0 :(得分:1)

OP的补充:

该问题与无意的只写属性有关。有setBlockListgetBlocklist(在getter中小&#39; l&#39;),这是一个错字。 Drools抱怨,因为它检测到两个属性,其中一个属性是只写的。

另一个不匹配是isFixedsetFixed。它适用于boolean内置,但不适用于Boolean对象。

我在mailing list post.

中解决了这个问题

答案 1 :(得分:0)

在5.4.0.Beta1(已发布)中修复了隐秘错误消息:https://issues.jboss.org/browse/JBRULES-3247