javascalajarnoclassdeffounderrorremote-actors

NoClassDefFoundError when running Scala jar file


I have a small application with RemoteActors, and I want to make a jar file from it. When I try to execute it it gets this exception:

Exception in thread "main" java.lang.reflect.InvocationTargetException
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:616)
  at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.NoClassDefFoundError: scala/actors/Combinators
  at pingpong.PingApp$.main(PingApp.scala:5)
  at pingpong.PingApp.main(PingApp.scala)
  at pingpong.ScalaEntryPoint.main(ScalaEntryPoint.java:5)
  ... 5 more
Caused by: java.lang.ClassNotFoundException: scala.actors.Combinators
  at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
  ... 8 more

I have included scala-library.jar in my jar file, and it is in the classpath. Otherwise java would stop at finding the class ScalaObject.


Solution

  • The problem was a version mismatch between the Scala plugin on Eclipse and the installed Scala version. actors/Combinators.scala appeared in 2.8, and the Eclipse plugin was 2.8 however I included 2.7.7 scala-library.jar