Uploaded image for project: 'OptaPlanner'
  1. OptaPlanner
  2. PLANNER-1015

setScoreDrlFileList() does not seem to work on Windows

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor Minor
    • 7.9.0.Final
    • 7.6.0.Final
    • optaplanner-core
    • None
    • 2018 Week 07-08
    • Hide

      Use the createSolverByApi() method in the optaplanner examples class
      org.optaplanner.examples.nqueens.app.NQueensApp
      and instead of setting the name of a classpath resource with scoreDirectorFactoryConfig.setScoreDrlList() open a file and feed it as a list into scoreDirectorFactoryConfig.setScoreDrlFileList()

      Show
      Use the createSolverByApi() method in the optaplanner examples class org.optaplanner.examples.nqueens.app.NQueensApp and instead of setting the name of a classpath resource with scoreDirectorFactoryConfig.setScoreDrlList() open a file and feed it as a list into scoreDirectorFactoryConfig.setScoreDrlFileList()
    • NEW
    • NEW

      To have the rule-files outside the classpath we use the scoredirector feature setScoreDrlFileList but it won't recognize the drool files.
      Instead i get an IllegalArgumentException

      I used the createSolverByApi() test from the NQeensExample:

      snippet:

      ScoreDirectorFactoryConfig scoreDirectorFactoryConfig = new ScoreDirectorFactoryConfig();
      File ruleFile = new File("src/main/resources/org/optaplanner/examples/nqueens/solver/nQueensScoreRules.drl");
      if (ruleFile.exists()) {
      scoreDirectorFactoryConfig.setScoreDrlFileList(Arrays.asList(ruleFile));
      } else {
      return null;
      }
      solverConfig.setScoreDirectorFactoryConfig(scoreDirectorFactoryConfig);
      ...
      when the buildSolver() function is called it returns with an expeception.

      java.lang.IllegalArgumentException: The kieBase with kiePackages ([]) has no global field called scoreHolder.
      Check if the rule files are found and if the global field is spelled correctly.
      at org.optaplanner.core.impl.score.director.drools.DroolsScoreDirectorFactory.checkIfGlobalScoreHolderExists(DroolsScoreDirectorFactory.java:96)
      at org.optaplanner.core.impl.score.director.drools.LegacyDroolsScoreDirectorFactory.<init>(LegacyDroolsScoreDirectorFactory.java:33)
      at org.optaplanner.core.config.score.director.ScoreDirectorFactoryConfig.buildDroolsScoreDirectorFactory(ScoreDirectorFactoryConfig.java:523)
      at org.optaplanner.core.config.score.director.ScoreDirectorFactoryConfig.buildScoreDirectorFactory(ScoreDirectorFactoryConfig.java:331)
      at org.optaplanner.core.config.solver.SolverConfig.buildSolver(SolverConfig.java:220)
      at org.optaplanner.core.impl.solver.AbstractSolverFactory.buildSolver(AbstractSolverFactory.java:61)
      at org.optaplanner.examples.nqueens.app.NQueensApp.createSolverByApi(NQueensApp.java:118)
      at org.optaplanner.examples.nqueens.app.NQueensAppTest.createSolverByApi(NQueensAppTest.java:30)

              rsynek@redhat.com Radovan Synek (Inactive)
              empting_jira Arnd Empting (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: