Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does sbt fail with NoClassDefFoundError: play/Play$ in Play 2.2.x projects after sbt compile in Play 2.3 project?

Once I run 'sbt compile' on a 2.3 play project, I can't use 'sbt compile' to compile any Play 2.2.x projects anymore. This is the error when I run sbt command.

[info] Loading project definition from /Users/macbookpro/playproject/project
[error] java.lang.NoClassDefFoundError: play/Play$
[error] Use 'last' for the full log.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?
like image 571
angelokh Avatar asked Jun 24 '14 22:06

angelokh


2 Answers

I just had this same issue. In my case I was using Play 2.4, but it's probably the same cause. I had run activator ui in my project directory accidentally. It created a project/play-fork-run.sbt file which is for activator support, but was preventing sbt from working directly. Deleting that file cleared up the issue and I can now use sbt again.

like image 102
Tim Gautier Avatar answered Oct 15 '22 07:10

Tim Gautier


That's interesting issue since it works for me (TM) on Mac OS X 10.9.3 with Java 7.

I downloaded the versions of Play - the latest 2.3.1 and the latest in 2.2.x stream - 2.2.3. With these two versions I've used activator (2.3.1) to create the web application and play for 2.2.3. Both worked well.

When I executed sbt compile in 2.3.1 and then 2.2.3, both commands worked fine, too. It took me some time to have all the dependencies downloaded, but at the end the results were as follows:

jacek:~/sandbox/play231-app
$ sbt compile
[info] Loading project definition from /Users/jacek/sandbox/play231-app/project
[info] Updating {file:/Users/jacek/sandbox/play231-app/project/}play231-app-build...
...
[info] Done updating.
[info] Compiling 5 Scala sources and 1 Java source to /Users/jacek/sandbox/play231-app/target/scala-2.11/classes...
[info] 'compiler-interface' not yet compiled for Scala 2.11.1. Compiling...
[info]   Compilation completed in 14.895 s
[success] Total time: 200 s, completed Jun 25, 2014 1:00:18 PM

And for 2.2.3:

jacek:~/sandbox/play223-app
$ sbt compile
[info] Loading project definition from /Users/jacek/sandbox/play223-app/project
[info] Set current project to play223-app (in build file:/Users/jacek/sandbox/play223-app/)
[info] Updating {file:/Users/jacek/sandbox/play223-app/}play223-app...
...
[info] Done updating.
[info] Compiling 5 Scala sources and 1 Java source to /Users/jacek/sandbox/play223-app/target/scala-2.10/classes...
[info] 'compiler-interface' not yet compiled for Scala 2.10.3. Compiling...
[info]   Compilation completed in 19.626 s
[success] Total time: 45 s, completed Jun 25, 2014 3:15:34 PM

I'm using sbt 0.13.5 installed using homebrew.

$ sbt --version
sbt launcher version 0.13.5

$ java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)
like image 39
Jacek Laskowski Avatar answered Oct 15 '22 09:10

Jacek Laskowski