[2.2.1-scala] SBT-only build stopped working

604 views
Skip to first unread message

Martin Simons

unread,
Jan 14, 2014, 10:11:53 AM1/14/14
to play-fr...@googlegroups.com
Hi,

I'm working on a Play Framework 2.2.1 app that works just fine in development. That is, when running it using the "play" command. So running this command works perfectly fine:

play clean compile dist
 

But when Jenkins tries to run the "sbt clean compile dist" command to set up the staging environment after a commit, it fails with something like this:

ara:core-app martin$ sbt clean compile dist

[info] Loading project definition from /Users/martin/development/ecosim/ecosim/core-app/project

[info] Set current project to ecosim-core (in build file:/Users/martin/development/ecosim/ecosim/core-app/)

[success] Total time: 0 s, completed 14.01.2014 16:04:38

[info] Updating {file:/Users/martin/development/ecosim/ecosim/core-app/}ecosim-core...

[info] Resolving org.fusesource.jansi#jansi;1.4 ...

[info] Done updating.

[info] Compiling 113 Scala sources and 4 Java sources to /Users/martin/development/ecosim/ecosim/core-app/target/scala-2.10/classes...

[error] /Users/martin/development/ecosim/ecosim/core-app/app/ecosim/services/SAR.scala:7: object ws is not a member of package play.api.libs

[error] import play.api.libs.ws._

[error]                      ^

[error] /Users/martin/development/ecosim/ecosim/core-app/app/ecosim/services/SAR.scala:41: not found: value WS

[error]       WS.url(url).withQueryString(

[error]       ^

[error] /Users/martin/development/ecosim/ecosim/core-app/app/ecosim/services/SAR.scala:61: not found: value WS

[error]       WS.url(url).withQueryString(

[error]       ^

[error] /Users/martin/development/ecosim/ecosim/core-app/app/ecosim/services/SAR.scala:80: not found: value WS

[error]       WS.url(url).withQueryString(

[error]       ^

[error] four errors found

[error] (compile:compile) Compilation failed

[error] Total time: 25 s, completed 14.01.2014 16:05:03


Interestingly, this problem is perfectly reproduceable locally on my development machine, but I have no clue as to why this is. I'm pretty sure it's a simple configuration issue, but so far I failed to figure it out.

My plugins.sbt looks like this:

// Comment to get more information during initialization

logLevel := Level.Warn

// The Typesafe repository 

resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// Use the Play sbt plugin for Play projects

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.1")


My build.properties looks like this:

 sbt.version=0.13.0


My Build.scala looks like this:

import sbt._

import Keys._

import play.Project._

object ApplicationBuild extends Build {

  val appName = "ecosim-core"

  val appVersion = "1.0-SNAPSHOT"

  val appDependencies = Seq(

    // Add your project dependencies here,

    jdbc, anorm,

    "com.typesafe.akka" %% "akka-cluster" % "2.2.0",

    "com.typesafe.akka" %% "akka-camel" % "2.2.0",

    "org.apache.camel" % "camel-rss" % "2.10.0",

    "postgresql" % "postgresql" % "9.1-901.jdbc4",

    "com.github.julienrf" %% "play-jsmessages" % "1.5.1"

  )

  val main = play.Project(appName, appVersion, appDependencies).settings(

    resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/",

    resolvers += "julienrf.github.com" at "http://julienrf.github.com/repo/",

    scalacOptions += "-feature",

    requireJs += "main.js",

    requireJsShim += "main.js",

    routesImport += "ecosim.core.api.Binders._",

    lessEntryPoints <<= baseDirectory(_ / "app" / "assets" / "stylesheets" ** "main.less")

  )

}

Any help or pointer would be greatly appreciated.

Thanks a lot,
Martin
 

Martin Simons

unread,
Jan 16, 2014, 8:11:11 AM1/16/14
to play-fr...@googlegroups.com
So I did some further investigating: I removed all references to Play's WS library from the pieces of code that caused the errors and interestingly, now the whole project compiles just fine.

Do I have to specify a dependency on Play's WebService library manually? If so why does it work out-of-the-box when using the play command? And why isn't it documented anywhere? Or did I stumble across a bug?

Either way, my problem isn't quite solved yet, since obviously I am dependent on the WS library. How do I get it to work?

Thanks a lot,
Martin

Martin Simons

unread,
Jan 23, 2014, 4:00:41 AM1/23/14
to play-fr...@googlegroups.com
I hate to push this, but I'm still completely stuck with this issue.

Today I came across this more recent post on the ML: https://groups.google.com/forum/#!topic/play-framework/ccqbkb9jeyM

The interesting tidbit of information there is this:

[...] the play command also configures sbt to use your play distribution to resolve dependencies

Might my problem be related to this? Has no one encountered this before?

Fernando Correia

unread,
Jan 23, 2014, 5:46:23 AM1/23/14
to play-fr...@googlegroups.com
Hi Martin,

First, are you sure you're calling the right sbt version? I prefer to use this loader:


This project is being built with sbt, it might help you:


I just created this small example, using the WS library, that builds with sbt:


Build result:

$ ./sbt clean compile test dist
[info] Loading project definition from /home/fernando/work/github/fernandoacorreia/play-sbt-example/project
[info] Set current project to play-sbt-example (in build file:/home/fernando/work/github/fernandoacorreia/play-sbt-example/)
[success] Total time: 0 s, completed Jan 23, 2014 8:42:39 AM
[info] Updating {file:/home/fernando/work/github/fernandoacorreia/play-sbt-example/}play-sbt-example...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Compiling 5 Scala sources and 1 Java source to /home/fernando/work/github/fernandoacorreia/play-sbt-example/target/scala-2.10/classes...
[success] Total time: 15 s, completed Jan 23, 2014 8:42:54 AM
[info] Compiling 2 Scala sources to /home/fernando/work/github/fernandoacorreia/play-sbt-example/target/scala-2.10/test-classes...
[info] IntegrationSpec
[info] Application should
[info] + work from within a browser
[info] Total for specification IntegrationSpec
[info] Finished in 7 seconds, 623 ms
[info] 1 example, 0 failure, 0 error
[info] ApplicationSpec
[info] Application should
[info] + send 404 on a bad request
[info] + render the index page
[info] Total for specification ApplicationSpec
[info] Finished in 402 ms
[info] 2 examples, 0 failure, 0 error
[info] Passed: Total 3, Failed 0, Errors 0, Passed 3
[success] Total time: 17 s, completed Jan 23, 2014 8:43:11 AM
[info] Packaging /home/fernando/work/github/fernandoacorreia/play-sbt-example/target/scala-2.10/play-sbt-example_2.10-1.0-SNAPSHOT-sources.jar ...
[info] Done packaging.
[info] Main Scala API documentation to /home/fernando/work/github/fernandoacorreia/play-sbt-example/target/scala-2.10/api...
[info] Wrote /home/fernando/work/github/fernandoacorreia/play-sbt-example/target/scala-2.10/play-sbt-example_2.10-1.0-SNAPSHOT.pom
[info] Packaging /home/fernando/work/github/fernandoacorreia/play-sbt-example/target/scala-2.10/play-sbt-example_2.10-1.0-SNAPSHOT.jar ...
[info] Done packaging.
model contains 17 documentable templates
[info] Main Scala API documentation successful.
[info] Packaging /home/fernando/work/github/fernandoacorreia/play-sbt-example/target/scala-2.10/play-sbt-example_2.10-1.0-SNAPSHOT-javadoc.jar ...
[info] Done packaging.
[info] 
[info] Your package is ready in /home/fernando/work/github/fernandoacorreia/play-sbt-example/target/universal/play-sbt-example-1.0-SNAPSHOT.zip
[info] 
[success] Total time: 7 s, completed Jan 23, 2014 8:43:18 AM
 

Martin Simons

unread,
Jan 23, 2014, 6:17:20 AM1/23/14
to play-fr...@googlegroups.com
Hi Fernando,

thanks for your elaborate reply!

I'm pretty sure the SBT version is correct. build.properties is set to version 0.13.0. I just tried 0.13.1 just for fun, with the same result. Using the alternative SBT caller you mentioned didn't help either. 

I also have several other apps based on Play 2.2.1, most of which use the WS library. All of these compile just fine, it's just this one that causes the issue. So I'm convinced it's an app-specific configuration issue.

What really confuses me is that building using the play command works just fine. The IDE (latest Scala IDE) doesn't show any problem what-so-ever, either. It only fails when calling sbt directly. 

Fernando Correia

unread,
Jan 23, 2014, 7:11:52 AM1/23/14
to play-fr...@googlegroups.com
I see. The only thing that occurs to me to suggest is to clear your ivy caches and whatever other caches, and doing  a sbt clean compile, watch carefully if all dependencies are being downloaded correctly, with the expected versions, specially those related to play.api.

I'm not really an expert in sbt. Perhaps you should try asking on SO:

Martin Simons

unread,
Jan 23, 2014, 7:40:25 AM1/23/14
to play-fr...@googlegroups.com
Not necessary...I just figured it out. But your tip to check the dependencies was the critical hint: I used the JsMessages plugin from https://github.com/julienrf/play-jsmessages. And apparently, this pulled in an older version of Play. After I removed it, the build worked fine. So many hours wasted :-)

Thanks again!

Fernando Correia

unread,
Jan 23, 2014, 9:22:32 AM1/23/14
to play-fr...@googlegroups.com
Good to know! 
Reply all
Reply to author
Forward
0 new messages