Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When running "play" java.lang.NoSuchMethodError occurs

I am trying to run a clone of the play project that I got from git clone https://github.com/djonmayer/play21-osm.git

I have play version 2.2.2 and scala version 2.10.4 installed.

When I type play in the directory that the project clones to I get the following error:

java.lang.NoSuchMethodError: scala.Predef$.augmentString(Ljava/lang/String;)Lscala/collection/immutable/StringOps;
    at sbt.ConsoleLogger$.<init>(ConsoleLogger.scala:129)
    at sbt.ConsoleLogger$.<clinit>(ConsoleLogger.scala)
    at sbt.StandardMain$.<init>(Main.scala:52)
    at sbt.StandardMain$.<clinit>(Main.scala)
    at sbt.xMain.run(Main.scala:26)
    at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:57)
    at xsbt.boot.Launch$.withContextLoader(Launch.scala:77)
    at xsbt.boot.Launch$.run(Launch.scala:57)
    at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45)
    at xsbt.boot.Launch$.launch(Launch.scala:65)
    at xsbt.boot.Launch$.apply(Launch.scala:16)
    at xsbt.boot.Boot$.runImpl(Boot.scala:32)
    at xsbt.boot.Boot$.main(Boot.scala:21)
    at xsbt.boot.Boot.main(Boot.scala)
Error during sbt execution: java.lang.NoSuchMethodError: scala.Predef$.augmentString(Ljava/lang/String;)Lscala/collection/immutable/StringOps;

This is true if I run play clean. I have read this may be a dependencies issue so I have tried adding the line scalaVersion := "2.10.4" to the play.Project.settings section of Build.scala and separately in a build.sbt file. It didn't work.

like image 540
Michael Richardson Avatar asked Apr 27 '14 07:04

Michael Richardson


2 Answers

I tried to put this in a comment but it was unreadable.

Thanks, zeppaman. It does look like this issue is to do with running a Play Framework project that was created in an older version of Play. By looking at another project that had commits for upgrading to a new play version I made the following changes.

In build.properties:

sbt.version=0.12.2

became:

sbt.version=0.13.0

In plugins.sbt:

addSbtPlugin("play" % "sbt-plugin" % "2.1.1")

became:

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

This enabled me to get to play update then throws the errors:

[error] Modules were resolved with conflicting cross-version suffixes in {file:/Users/michaelrichardson/Documents/Play/play21-osm/}play21-osm:
[error]    org.scala-stm:scala-stm _2.10, _2.10.0
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) Conflicting cross-version suffixes in: org.scala-stm:scala-stm

I change the line in Build.scala:

    "com.typesafe.play" %% "play-slick" % "0.3.2"

became:

    "com.typesafe.play" %% "play-slick" % "0.5.0.2-SNAPSHOT"

EXTRA: This changes the error to:

[info] Resolving com.typesafe.play#play-slick_2.10;0.5.0.2-SNAPSHOT ...
[warn]  module not found: com.typesafe.play#play-slick_2.10;0.5.0.2-SNAPSHOT
[warn] ==== Typesafe Releases Repository: tried
[warn]   http://repo.typesafe.com/typesafe/releases/com/typesafe/play/play-slick_2.10/0.5.0.2-SNAPSHOT/play-slick_2.10-0.5.0.2-SNAPSHOT.pom
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.typesafe.play#play-slick_2.10;0.5.0.2-SNAPSHOT: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: com.typesafe.play#play-slick_2.10;0.5.0.2-SNAPSHOT: not found

UPDATE: Solved unresolved dependency

The problem of unresolved dependencies seems like it may have been due to my local sbt/ivy repositories getting corrupted. See unresolved dependency: com.typesafe.play#play-slick_2.10;0.6.0.1: not found

like image 128
Michael Richardson Avatar answered Nov 03 '22 01:11

Michael Richardson


This kind of problem is often relate to two similar prolbem:

  • missing jar with same class
  • same class into multiple jar

So check if scala and play version are compatible and if You have included a jar that already contains the class with missing method.

like image 23
zeppaman Avatar answered Nov 03 '22 00:11

zeppaman