Patrick
Patrick

Reputation: 53

Eclipse can't find class DefaultSolver of OptaPlanner and throws ClassNotFoundException

Hi I'm building a program using optaplanner, and everything seems to be imported and working fine, but when I run and debug the code, I get a ClassNotFoundException "org.optaplanner.core.impl.solver.DefaultSolver". I believe I've imported all the jar files correctly, but just to be sure, what jar file is the DefaultSolver class in?

As a follow up, I keep getting prompted to edit the source lookup path. This happens after running SolverConfig.buildSolver() line 156: "DefaultSolver solver = new DefaultSolver();" I'm running OptaPlanner 6.1.0.Final.

Upvotes: 1

Views: 379

Answers (2)

Patrick
Patrick

Reputation: 53

Found the problem, I realized that I had both imported the examples jar file into my buildpath and at one point imported a class from the examples jar file when I was messing around with the examples. Rereading the manual I saw it explicitly said not to import the examples jar file, so I unimported that and found the culprit pretty fast. Thanks for your help.

Upvotes: 1

Geoffrey De Smet
Geoffrey De Smet

Reputation: 27312

Both the class SolverConfig and the class DefaultSolver are in the jar optaplanner-core-*.jar.

So this doesn't make sense: if the jar is in the classpath, it should find DefaultSolver. If the jar is not in the classpath, it shouldn't even find SolverConfig. What you're seeing can never happen in a normal classpath.

Are you using anything like OSGi, JBoss modules, jigsaw, Karaff or other classloading magic?

Upvotes: 0

Related Questions