Guilherme Scofano Guilherme Scofano - 2 months ago 9
Scala Question

Compilation error following Play! Framework NewApplication guide

I use Fedora 22 OS and I'm trying to get started with Play! Framework. Naturally, I'm trying to build the simplest application possible so I can have a starting point.

I tried to follow the guide at the documentation (https://www.playframework.com/documentation/2.4.x/NewApplication) as close as I could, but I'm getting no success here. It fails when I call the activator inside the base folder of the project and indicates me some unresolved dependencies. I'll post the steps I've taken so I can show what I've done and the problem as clearly as possible, including some information about Java (I read somewhere I should use Oracle Java instead of OpenJDK, so I downloaded the latest Java SE JDK 7) and sbt, which I belive to be related to the process.
My OS is in portuguese, so a few lines will be in portuguese, but as they refer to well known commands (basically the command alternatives), I don't think it will harm the comprehension.

su -

[root@localhost ~]# alternatives --config java

Há 3 programas que oferecem "java".

Seleção Comando
-----------------------------------------------
*+ 1 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.45-36.b13.fc22.x86_64/jre/bin/java
2 /usr/java/jdk1.7.0_79/bin/java
3 /usr/java/default/jre/bin/java

Indique para manter a seleção atual[+] ou digite o número da seleção: 2

[root@localhost ~]# alternatives --config javac

Há 1 programa que oferece "javac".

Seleção Comando
-----------------------------------------------
*+ 1 /usr/java/default/bin/javac


[root@localhost ~]# alternatives --config javaws

Há 1 programa que oferece "javaws".

Seleção Comando
-----------------------------------------------
*+ 1 /usr/java/default/jre/bin/javaws

Indique para manter a seleção atual[+] ou digite o número da seleção: 1

[root@localhost ~]# alternatives --config jar

Há 1 programa que oferece "jar".

Seleção Comando
-----------------------------------------------
*+ 1 /usr/java/default/bin/jar

Indique para manter a seleção atual[+] ou digite o número da seleção: 1

[root@localhost ~]# exit
logout

[gscofano@localhost new-project]$ java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

[gscofano@localhost new-project]$ javac -version
javac 1.7.0_79


[gscofano@localhost new-project]$ pwd
/home/gscofano/Documentos/Programacao/play/play-2.4.2


[gscofano@localhost new-project]$ ls
activator-1.3.5-minimal


[gscofano@localhost new-project]$ mkdir new-project


[gscofano@localhost new-project]$ cd ./new-project


[gscofano@localhost new-project]$ sbt about

[info] Set current project to new-project (in build file:/home/gscofano/Documentos/Programacao/play/play-2.4.2/new-project/)
[info] This is sbt 0.13.1
[info] The current project is {file:/home/gscofano/Documentos/Programacao/play/play-2.4.2/new-project/}new-project 0.1-SNAPSHOT
[info] The current project is built against Scala 2.10.4
[info]
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.4


[gscofano@localhost new-project]$ ../activator-1.3.5-minimal/activator new first-app play-java

OK, application "first-app" is being created using the "play-java" template.

To run "first-app" from the command line, "cd first-app" then:
/home/gscofano/Documentos/Programacao/play/play-2.4.2/new-project/first-app/activator run

To run the test for "first-app" from the command line, "cd first-app" then:
/home/gscofano/Documentos/Programacao/play/play-2.4.2/new-project/first-app/activator test

To run the Activator UI for "first-app" from the command line, "cd first-app" then:
/home/gscofano/Documentos/Programacao/play/play-2.4.2/new-project/first-app/activator ui


[gscofano@localhost new-project]$ cd ./first-app


[gscofano@localhost first-app]$ ./activator
[info] Loading project definition from /home/gscofano/Documentos/Programacao/play/play-2.4.2/new-project/first-app/project
[info] Updating {file:/home/gscofano/Documentos/Programacao/play/play-2.4.2/new-project/first-app/project/}first-app-build...
[info] Resolving org.scala-sbt#precompiled-2_9_3;0.13.8 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.scala-lang#scala-library;2.10.4: configuration not found in org.scala-lang#scala-library;2.10.4: 'master(compile)'. Missing configuration: 'compile'. It was required from com.typesafe#npm_2.10;1.1.1 compile
[warn] :: org.scala-lang#scala-compiler;2.10.4: configuration not found in org.scala-lang#scala-compiler;2.10.4: 'master(compile)'. Missing configuration: 'compile'. It was required from com.typesafe.play#twirl-compiler_2.10;1.1.1 compile
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] org.scala-lang:scala-library:2.10.4 ((sbt.Classpaths) Defaults.scala#L1203)
[warn] +- org.scala-sbt:control:0.13.8
[warn] +- org.scala-sbt:io:0.13.8
[warn] +- org.scala-sbt:classpath:0.13.8
[warn] +- org.scala-sbt:incremental-compiler:0.13.8
[warn] +- org.scala-sbt:persist:0.13.8
[warn] +- org.scala-sbt:compiler-integration:0.13.8
[warn] +- org.scala-sbt:actions:0.13.8
[warn] +- org.scala-sbt:main:0.13.8
[warn] +- org.scala-sbt:sbt:0.13.8
[warn] +- default:first-app-build:0.1-SNAPSHOT (sbtVersion=0.13, scalaVersion=2.10)
[warn] org.scala-lang:scala-compiler:2.10.4
[warn] +- org.scala-sbt:classpath:0.13.8
[warn] +- org.scala-sbt:incremental-compiler:0.13.8
[warn] +- org.scala-sbt:persist:0.13.8
[warn] +- org.scala-sbt:compiler-integration:0.13.8
[warn] +- org.scala-sbt:actions:0.13.8
[warn] +- org.scala-sbt:main:0.13.8
[warn] +- org.scala-sbt:sbt:0.13.8
[warn] +- default:first-app-build:0.1-SNAPSHOT (sbtVersion=0.13, scalaVersion=2.10)
sbt.ResolveException: unresolved dependency: org.scala-lang#scala-library;2.10.4: configuration not found in org.scala-lang#scala-library;2.10.4: 'master(compile)'. Missing configuration: 'compile'. It was required from com.typesafe#npm_2.10;1.1.1 compile
unresolved dependency: org.scala-lang#scala-compiler;2.10.4: configuration not found in org.scala-lang#scala-compiler;2.10.4: 'master(compile)'. Missing configuration: 'compile'. It was required from com.typesafe.play#twirl-compiler_2.10;1.1.1 compile
at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:291)
at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:188)
at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:165)
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:155)
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:155)
at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:132)
at sbt.IvySbt.sbt$IvySbt$$action$1(Ivy.scala:57)
at sbt.IvySbt$$anon$4.call(Ivy.scala:65)
at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:93)
at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:78)
at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:97)
at xsbt.boot.Using$.withResource(Using.scala:10)
at xsbt.boot.Using$.apply(Using.scala:9)
at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:58)
at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:48)
at xsbt.boot.Locks$.apply0(Locks.scala:31)
at xsbt.boot.Locks$.apply(Locks.scala:28)
at sbt.IvySbt.withDefaultLogger(Ivy.scala:65)
at sbt.IvySbt.withIvy(Ivy.scala:127)
at sbt.IvySbt.withIvy(Ivy.scala:124)
at sbt.IvySbt$Module.withModule(Ivy.scala:155)
at sbt.IvyActions$.updateEither(IvyActions.scala:165)
at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1369)
at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1365)
at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$87.apply(Defaults.scala:1399)
at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$87.apply(Defaults.scala:1397)
at sbt.Tracked$$anonfun$lastOutput$1.apply(Tracked.scala:37)
at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1402)
at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1396)
at sbt.Tracked$$anonfun$inputChanged$1.apply(Tracked.scala:60)
at sbt.Classpaths$.cachedUpdate(Defaults.scala:1419)
at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1348)
at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1310)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
at sbt.std.Transform$$anon$4.work(System.scala:63)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.Execute.work(Execute.scala:235)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
[error] (*:update) sbt.ResolveException: unresolved dependency: org.scala-lang#scala-library;2.10.4: configuration not found in org.scala-lang#scala-library;2.10.4: 'master(compile)'. Missing configuration: 'compile'. It was required from com.typesafe#npm_2.10;1.1.1 compile
[error] unresolved dependency: org.scala-lang#scala-compiler;2.10.4: configuration not found in org.scala-lang#scala-compiler;2.10.4: 'master(compile)'. Missing configuration: 'compile'. It was required from com.typesafe.play#twirl-compiler_2.10;1.1.1 compile
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?


Here is build.sbt

name := """first-app"""

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayJava)

scalaVersion := "2.11.6"

libraryDependencies ++= Seq(
javaJdbc,
cache,
javaWs
)

// Play provides two styles of routers, one expects its actions to be injected, the
// other, legacy style, accesses its actions statically.
routesGenerator := InjectedRoutesGenerator


build properties

#Activator-generated Properties
#Sat Aug 01 03:30:20 BRT 2015
template.uuid=4908845b-9453-410b-af0f-404c1440dff1
sbt.version=0.13.8


And plugins.sbt

// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.2")

// Web plugins
addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.0.6")
addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.3")
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.7")
addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.0")

// Play enhancer - this automatically generates getters/setters for public fields
// and rewrites accessors of these fields to use the getters/setters. Remove this
// plugin if you prefer not to have this feature, or disable on a per project
// basis using disablePlugins(PlayEnhancer) in your build.sbt
addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.1.0")

// Play Ebean support, to enable, uncomment this line, and enable in your build.sbt using
// enablePlugins(SbtEbean). Note, uncommenting this line will automatically bring in
// Play enhancer, regardless of whether the line above is commented out or not.
// addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "1.0.0")


I tried to separate the lines in this last file with blank lines. Nothing changes.

I tried to google this, but I couldn't find anything like. I'd appreciate very much if somebody could help me with this issue. And, finally, I'd like to thank all the readers who dedicated their time in reading this question.

edit: I just realized I was using /usr/default/jre/bin/javac. I fixed that to /usr/jdk1.8.0_51/jre/bin/javac when I tried Java SDK 8.

Answer

FINALLY, I've come to a solution. That was a hard one.

So, the problem was a couple of dependencies that, for some reason, sbt wasn't able to download by itself. In order to solve that, I set up an ivy build file and used ant to download them without using play, sbt, or anything related to that. I'll post more details in the end of my post.

I used the activator user interface (/play-2.4.2/activator-dist-1.3.5/activator ui) and it started to build the project again. It went through the problematic point and failed a bit later. More dependencies that couldn't be downloaded. I used the same method to download them. It worked for all the dependencies but one, which was com.typesafe.sbtrc#actor-client-2-10;0.3.1. Ivy looks inside maven repositories for the dependencies I download with ant and this last one was inside bintray repositories, not used, by default at least, by ivy. I accessed this repository (http://dl.bintray.com/typesafe/ivy-releases/com.typesafe.sbtrc/) in my web browser, downloaded the module that was inside it and put inside ~/ivy/local/com.typesafe.sbtrc/.

I called the activator user interface again and it could, finally, build and run my project.

Explaining the situation a bit more, for those who had this problem with the actor-client-2-10 dependency, when the activator builds the project, it looks inside maven repositories and the local ones, but not the bintray repositories! All I did was copying the module that would be found in bintray to my local repository. When activator looked into ~/.ivy2/local, it found the artifact it wanted and installed it inside ~/.ivy2/cache.

If you did the same to fix this problem, please remember to create some directories so that the directory tree is the same in the bintray repository and in your local one.

Well, as promised, I'll post the ivy build file I used to download the problematic dependencies. First, we have to download and install ant. Then, we go to any directory and create a file called build.xml. In terminal, cd to this directory and type ant. It will download and install the dependency defined in build.xml. The contents of this file should be

<project name="localrepository" default="install" xmlns:ivy="antlib:org.apache.ivy.ant">
 <target name="install" description="--> install modules to localreporsitory">
  <ivy:install organisation="TYPE HERE ORGANISATION" module="TYPE HERE THE MODULE"
   revision="TYPE HERE THE REVISION" transitive="true" overwrite="true" 
   from="public" to="local" />
 </target>
</project>

As I used it first to

Let's use the first dependency that gave me problems as an example. The activator reported that the dependency was org.scala-lang#scala-library;2.10.4. As it follows the model organisation#module;revision, our build.xml file to install this dependency will be

<project name="localrepository" default="install" xmlns:ivy="antlib:org.apache.ivy.ant">
 <target name="install" description="--> install modules to localreporsitory">
  <ivy:install organisation="org.scala-lang" module="scala-library"
   revision="2.10.4" transitive="true" overwrite="true" 
   from="public" to="local" />
 </target>
</project>
Comments