Drools planner says “Solving failed” with NullpointerException
-
24-06-2021 - |
Question
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.
Solution
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.
OTHER TIPS
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).