Question

I tried to create a solver from XML configuration. But the entire process returns a cryptic error message that makes no sense.

How do I fix this? And how can I make sense of this to actually solve similar problems like this?

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)

The function that throws it is listed here. The line is of course 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();
}

The content of the 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>
Était-ce utile?

La solution

Cryptic error message is fixed in 5.4.0.Beta1 (already released): https://issues.jboss.org/browse/JBRULES-3247

Autres conseils

OP's addition:

The issue was related to an inadvertent write-only property. There was setBlockList and getBlocklist (small 'l' in the getter), which was a typo. Drools complained because it detected two properties, one of which was write-only.

The other mismatch was isFixed and setFixed. It works for boolean built-in, but not for Boolean object.

I solved the issue in a mailing list post.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top