2016-06-06 32 views
1

Für das Leben von mir my scala build tool project ist nur mit ClassNotFoundExceptions gespickt.ClassNotFoundException in sbt Projekt

Alles, was ich tun müssen, um Klon ist und tun sbt run und ich

java.lang.NoClassDefFoundError: com/example/Utils$$anonfun$1 
     at com.example.Utils$.shortenTypeSignature(Utils.scala:10) 
     at com.example.Hello$.getTypedDeclaration$1(Hello.scala:69) 
     at com.example.Hello$.iterateThroughSourceFile$1(Hello.scala:113) 
     at com.example.Hello$.main(Hello.scala:157) 
     at com.example.Hello.main(Hello.scala) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
     at java.lang.reflect.Method.invoke(Method.java:497) 
Caused by: java.lang.ClassNotFoundException: com.example.Utils$$anonfun$1 
     at java.net.URLClassLoader.findClass(URLClassLoader.java:381) 
     at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
     at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
     at com.example.Utils$.shortenTypeSignature(Utils.scala:10) 
     at com.example.Hello$.getTypedDeclaration$1(Hello.scala:69) 
     at com.example.Hello$.iterateThroughSourceFile$1(Hello.scala:113) 

Zuvor hatte ich eine Variable vom Typ GlobFinder in Hello.scala einzufügen oder sonst würde ich:

/* 
Exception in thread "main" java.lang.NoClassDefFoundError: info/collaboration_station/utilities/GlobFinder 
    at info.collaboration_station.utilities.FileFinder.tryFindAbsolutePathOfFileWhoseNameIs(FileFinder.java:128) 
    at com.example.Hello$.main(Hello.scala:137) 
    at com.example.Hello.main(Hello.scala) 
Caused by: java.lang.ClassNotFoundException: info.collaboration_station.utilities.GlobFinder 
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
    ... 3 more 
*/ 

Fix war diese Zeile hinzufügen ...

val vvv = new GlobFinder("foo") 

Warum ist my Scala project so häufig mit ClassNotFoundExceptions?

Antwort

0

Ich denke, ich habe es herausgefunden. Das Projekt läuft clean auf sich selbst. Es muss seine eigenen Klassendateien löschen.

aber sagen, dass clean von

val proc = Runtime.getRuntime.exec(Array[String]("sbt", "clean", "set scalacOptions in ThisBuild ++= Seq(\"-print\")", "compile", "exit"))

^in Hello.scala Entfernen nicht alles reparieren haben.