0
votes

I'm experiencing a problem when running latest play framework 2.3. It compiles just fine, although when I do activator run this error happens:

java.lang.NoSuchMethodError: scala.Predef$.ArrowAssoc(Ljava/lang/Object;)Ljava/lang/Object;

Full error log

I explicitly tried scalaVersion in every build.sbt file and it is the same. I tried several things like activator clean, full removal os sbt caches and local repo sbt stuff, updating dependencies to latest version but no success. I have scala version defined.

My current dependencies are: I tried with both %% and force _2.11 in the name of the dependency.

Dependency List

Other important files

build.sbt

Common.scala

Dependencies.scala

When I fully clean caches it downloads scala 2.10.4 for no reason: in this download log it says the sbt need the old scala. Any idea why is this?

Any ideas?

3
You are using the ws dependency as provided by Play, but you are importing the JDBC and JSON libraries seperately. Why is that? - DCKing
That is for a sub project that doesn't need all the play. - rtfpessoa
This seems relevant: stackoverflow.com/questions/13098856/… . What if you add scalaVersion in more places? - DCKing
I tried with scalaVersion explicitly in every build.sbt file and it is exactly the same. - rtfpessoa
DCKing I just added a log of the downloads, do you have any idea why is that? - rtfpessoa

3 Answers

1
votes

Firstly, it does not matter which version of Scala is used to generate your build. The build system can use version 2.10.4, and that does not prevent your code from using version 2.11.1.

To look at the issue with your scala version, you should consider that settings added directly in build.sbt are added to the root project, but not to other projects. You can see this with a minimal project such as:

$ cat build.sbt
scalaVersion := "2.11.1"

lazy val subproj = project in (file("subproj"))

Then the output of sbt looks like this:

> show scalaVersion
[info] subproj/*:scalaVersion
[info]  2.10.4
[info] sbttest/*:scalaVersion
[info]  2.11.1

So, how can this be fixed?

We can create a lazy val containing a Seq[Setting[_]], and add it to the sub-project definition with the settings() method.

Here's an example build.sbt which adds the same settings to all projects:

$ cat build.sbt
lazy val root = project.in(file("."))
  .aggregate(subproj)
  .dependsOn(subproj)
  .settings(commonSettings: _*)

lazy val subproj = project.in(file("subproj"))
  .settings(commonSettings: _*)

lazy val commonSettings = Seq(
  scalaVersion := "2.11.1"
)

The _* is required because settings() is defined as requiring Setting[_]* rather than Seq[Setting[_]], so _* converts between the two types. See also: What does param: _* mean in Scala?

And the output from sbt is:

> show scalaVersion
[info] subproj/*:scalaVersion
[info]  2.11.1
[info] root/*:scalaVersion
[info]  2.11.1

This approach can easily be applied to your build.

0
votes

You're defining your dependencies in the wrong way.

When using SBT, don't use:

"org.mydep" % "mydep_2.11" % "1.0.0"

Instead use:

"org.mydep" %% "mydep" % "1.0.0"

The %% operator automatically appends the current Scala version of the current build. If you use dependencies built against other Scala versions, you're going to be getting the weird errors.

Also make sure you explicitly specify your Scala version somewhere:

scalaVersion := "2.11.1"
0
votes

The problem was related to some manually added jars that I discovered in the lib folder, that were causing issues with the dependencies of the project defined in the build.sbt. The only way to find out was to generate a activator dist and look for similar dependencies with different versions since in the dependency graph there were no conflicts