Shailesh
Shailesh

Reputation: 388

Error during sbt execution: java.lang.NoClassDefFoundError: scala/StringContext

I am trying to run a play framework(2.1) application which is written in Scala but getting some error.

I need to use Play framework 2.1 only. As per build.sbt file, I am using Scala 2.11.7. sbt.version=0.13.8 is in project/build.properties.

I have installed Play 2.1.0 and changed my directory to application's root directory and then executed play command.

I got following error:

java.lang.NoClassDefFoundError: scala/StringContext

    at sbt.CommandStrings$.<init>(CommandStrings.scala:83)
    at sbt.CommandStrings$.<clinit>(CommandStrings.scala)
    at sbt.BuiltinCommands$.defaults(Main.scala:202)
    at sbt.xMain.run(Main.scala:29)
    at xsbt.boot.Launch$.run(Launch.scala:55)
    at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45)
    at xsbt.boot.Launch$.launch(Launch.scala:69)
    at xsbt.boot.Launch$.apply(Launch.scala:16)
    at xsbt.boot.Boot$.runImpl(Boot.scala:31)
    at xsbt.boot.Boot$.main(Boot.scala:20)
    at xsbt.boot.Boot.main(Boot.scala)
Caused by: java.lang.ClassNotFoundException: scala.StringContext
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 11 more

Error during sbt exeenter code herecution: java.lang.NoClassDefFoundError: scala/StringContext

Can someone please tell me what's wrong here?

I am completely new to scala and I just need to run this app at earliest. I am using 64-bit Cent OS 7(in case someone wants to know about OS).

Upvotes: 2

Views: 2570

Answers (2)

Raashi
Raashi

Reputation: 141

sbt.version=0.12.2 wont work with JDK8 so you might need to downgrade Java. I used this sbt version and got the following error

eror: error while loading CharSequence, class file '/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/rt.jar(java/lang/CharSequence.class)' is broken for sbt 0.12.2

Upvotes: 1

Salem
Salem

Reputation: 12986

The easiest way to fix that is to use an older version of SBT. Play 2.1.5 uses 0.12.2 by default, so you can change the file project/build.properties inside your project and use that version:

sbt.version=0.12.2

You can later try newer versions of SBT if you need.

Upvotes: 2

Related Questions