开发者

ClassNotFoundException on Marshal.load

I'm trying to do a marshal dump and load in Scala...

import scala.util.Marshal

case class Test(test: String)

val t = Test("hello")
val bytes = Marshal.dump(t)
Marshal.load[Test](bytes)

...but the call to Marshal.load is throwing a ClassNotFoundException...

java.lang.ClassNotFoundException: Test
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:30开发者_高级运维7)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:603)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1574)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
at java.io.ObjectInputStream.readClass(ObjectInputStream.java:1461)
at java.io.Ob...

I've also tried using the fully qualified class name but with no luck. What am I missing?


Which version of SBT are you using? I had similar problems with SBT 0.7.7 and resolved them by adding the following to my build:

// cause the SBT "run" action to fork                                                                                                              
override def fork = Some(new ForkScalaRun() {
  override def scalaJars = Seq(buildLibraryJar.asFile, buildCompilerJar.asFile)
})

Causing the "run" action to fork seems to resolve class loader problems, and problems with trapping System.exit calls:

http://code.google.com/p/simple-build-tool/wiki/Forking

http://code.google.com/p/simple-build-tool/wiki/RunningProjectCode

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜