WestCoastProjects
WestCoastProjects

Reputation: 63022

Kafka scalaConsole has ClassNotFoundException

When starting scalaConsole from gradlew, the main Scala runner is not found on the classpath:

05:21:45/kafka-0.8.1-src:43 $./gradlew scalaConsole
The TaskContainer.add() method has been deprecated and is scheduled to be removed in Gradle 2.0. Please use the create() method instead.
Building project 'core' with Scala version 2.8.0
Building project 'perf' with Scala version 2.8.0
:core:compileJava UP-TO-DATE
:core:compileScala UP-TO-DATE
:core:processResources UP-TO-DATE
:core:classes UP-TO-DATE
:core:scalaConsole
Exception in thread "main" java.lang.NoClassDefFoundError: scala/tools/nsc/MainGenericRunner
Caused by: java.lang.ClassNotFoundException: scala.tools.nsc.MainGenericRunner
    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:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
:core:scalaConsole FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':core:scalaConsole'.
> Process 'command '/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Upvotes: 2

Views: 255

Answers (1)

Mark
Mark

Reputation: 1854

From http://sethrylan.org/2013/07/02/scala-gradle-scalaconsole.html, try adding the compiler to your runtime dependencies.

dependencies {
  runtime "org.scala-lang:scala-compiler:2.10.4"
  compile "org.scala-lang:scala-library:2.10.4"
}

The same article suggests starting it with Gradle's -q option:

$ gradle scalaConsole -q

Note that I don't think this is a very good solution since you really don't want to make your code dependent on the compiler, but at least it's a workaround.

Upvotes: 1

Related Questions