0

I used the examination example of drools planner to create my own example. I renamed the classes und erased every rule except one. The application started and I could load my XML-File. When clicking the "solve"-Button an error occured:

pool-2-thread-1] ERROR swingui.SolverAndPersistenceFrame - Solving failed.
java.lang.NullPointerException: null

Could anybody give me hint to fix the problem? I don't know what the error message means.

Thank you.

Vivid
  • 399
  • 1
  • 8
  • 19

2 Answers2

0

It was the entire error message!

The problem was the cloneSolution method. I forget to implement the method. So the solver could not find a solution because it has to clone my objects.

For everybody: Don't forget to implement this method and to copy the score attribute. Without a score the won't be a real solution.

Vivid
  • 399
  • 1
  • 8
  • 19
  • 1
    If that's the entire error message, and your code doesn't wrap the call with a try-catch block that handles the fail fast exception, then it's a bug in Planner. Please [report it](https://issues.jboss.org/browse/JBRULES). What version of Planner did you use? – Geoffrey De Smet Aug 06 '12 at 06:40
  • @GeoffreyDeSmet, I (and atleast one other guy) have asked questions on SO on this very error. Please make the documents perfectly clear on what a `cloneSolution` must do, or write something to catch such errors. – Jesvin Jose Aug 08 '12 at 10:26
  • @aitchnyu I can't reproduce this error on 5.5.0-SNAPSHOT. See the other answer in this question. There, the stacktrace is clearly visible. Unless I can reproduce it, I can't fix it. My current guesses are that either it's fixed in 5.5.0 or you're using slf4j, but not configuring logging and ignoring slf4j warnings. – Geoffrey De Smet Aug 09 '12 at 09:05
  • Sorry I was lazy, but I was using 5.4-beta; if I recall correctly, you recommended to me over 5.3 for some bug fix. And I used the highest logging level too. – Jesvin Jose Aug 09 '12 at 09:41
0

On Planner 5.5.0.Beta1's SNAPSHOT, I added a NPE in the cloneSolution method and got this stacktrace:

2012-08-06 08:56:08,157 [AWT-EventQueue-0] INFO  Loaded: data/cloudbalancing/unsolved/cb-0100comp-0300proc.xml
2012-08-06 08:56:09,122 [pool-2-thread-1] ERROR Solving failed.
java.lang.NullPointerException: null
    at org.drools.planner.examples.cloudbalancing.domain.CloudBalance.cloneSolution(CloudBalance.java:92) ~[classes/:na]
    at org.drools.planner.examples.cloudbalancing.domain.CloudBalance.cloneSolution(CloudBalance.java:31) ~[classes/:na]
    at org.drools.planner.core.solver.DefaultSolverScope.setWorkingSolutionFromBestSolution(DefaultSolverScope.java:154) ~[classes/:na]
    at org.drools.planner.core.solver.DefaultSolver.solvingStarted(DefaultSolver.java:176) ~[classes/:na]
    at org.drools.planner.core.solver.DefaultSolver.solve(DefaultSolver.java:154) ~[classes/:na]
    at org.drools.planner.examples.common.business.SolutionBusiness.solve(SolutionBusiness.java:276) ~[classes/:na]
    at org.drools.planner.examples.common.swingui.SolverAndPersistenceFrame$SolveAction$1.run(SolverAndPersistenceFrame.java:252) ~[classes/:na]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [na:1.6.0_26]
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [na:1.6.0_26]
    at java.util.concurrent.FutureTask.run(FutureTask.java:138) [na:1.6.0_26]
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [na:1.6.0_26]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [na:1.6.0_26]
    at java.lang.Thread.run(Thread.java:662) [na:1.6.0_26]

So the stacktrace eating code must be in your custom SolverAndPersistenceFrame code (which might be copied from an older Planner version that might had such a bug).

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120