Why does sbt fail with NoClassDefFoundError: play/

2019-01-25 07:57发布

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?

5条回答
唯我独甜
2楼-- · 2019-01-25 08:25

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.

查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-01-25 08:31

I had the same issue. Make sure that you are using the java-8 version. I was using java-7, changing to java-8 fixed my problem.

查看更多
迷人小祖宗
4楼-- · 2019-01-25 08:33

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)
查看更多
Luminary・发光体
5楼-- · 2019-01-25 08:34

Try updating play-fork-run.sbt

addSbtPlugin("com.typesafe.play" % "sbt-fork-run-plugin" % "2.3.8")

update to

addSbtPlugin("com.typesafe.play" % "sbt-fork-run-plugin" % "2.4.0")

Then project will be able to build.

查看更多
beautiful°
6楼-- · 2019-01-25 08:35

Play 2.3 app is supposed to be built using activator, to ensure proper sbt configuration. Best

查看更多
登录 后发表回答