vendredi 24 juillet 2015

Scala 2.11.6 scala.tools.reflect.package$.ToolBox error at test time

I'm experiencing a strange behavior of the scala 2.11 reflection library.

In a simple application that uses the sorm-framework I can invoke persistence methods from the console:

[INFO] Building sorm-test 1.0-SNAPSHOT

[INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- scala-maven-plugin:3.2.0:console (default-cli) @ sorm-test --- [WARNING] Expected all dependencies to require Scala version: 2.11.6 [WARNING] org.scala-lang:scala-reflect:2.11.0 requires scala version: 2.11.6 [WARNING] sorm-test:sorm-test:1.0-SNAPSHOT requires scala version: 2.11.6 [WARNING] com.github.nikita-volkov:sext:0.2.4 requires scala version: 2.11.6 [WARNING] com.typesafe.scala-logging:scala-logging-slf4j_2.11:2.1.2 requires scala version: 2.11.0 [WARNING] Multiple versions of scala libraries detected! [WARNING] scala-maven-plugin cannot fork scala console!! Running in process Welcome to Scala version 2.11.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_40). Type in expressions to have them evaluated. Type :help for more information.

scala> import TestRun._

import TestRun._

scala> TestRun.dodb()

TestRun.dodb()

Some(Artist(2,Map(Locale(2,en) -> Vector(Nirvana), Locale(1,ru) -> Vector(Нирвана)),Set(Genre(1,Map(Locale(2,en) -> Vector(Rock), Locale(1,ru) -> Vector(Рок))), Genre(2,Map(Locale(2,en) -> Vector(Hard Rock), Locale(1,ru) -> Vector(Тяжёлый рок, Тяжелый рок))), Genre(4,Map(Locale(2,en) -> Vector(Grunge), Locale(1,ru) -> Vector(Грандж))))))

But if I call the same method from a Test (scalatest)

class TestDb  extends FlatSpec with Matchers  {
import TestRun._

"A test db" should "save Stuff" in {
    TestRun.dodb()
}

}

I got this exception:

java.lang.NoSuchMethodError: scala.tools.reflect.package$.ToolBox(Lscala/reflect/api/JavaUniverse$JavaMirror;)Lscala/tools/reflect/ToolBoxFactory;

at sorm.persisted.PersistedClass$.createClass(PersistedClass.scala:104)

Now I triple checked and scaliest is not the issue: it has a dependency from scala 2.11.6 as everything else

INFO] --- scala-maven-plugin:3.2.0:testCompile (compile) @ sorm-test --- [WARNING] Expected all dependencies to require Scala version: 2.11.6 [WARNING] org.scala-lang:scala-reflect:2.11.0 requires scala version: 2.11.0 [WARNING] Multiple versions of scala libraries detected! [WARNING] Zinc server is not available at port 3030 - reverting to normal incremental compile [INFO] Using incremental compilation [INFO] Compiling 1 Scala source to /Users/sam/dev/projects/sorm-test/target/test-classes... [INFO] [INFO] --- maven-surefire-plugin:2.10:test (default-test) @ sorm-test --- [INFO] Surefire report directory: /Users/sam/dev/projects/sorm-test/target/surefire-reports


T E S T S

Running TestDb Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 3.679 sec <<< FAILURE!

Results :

Tests in error: TestDb: scala.tools.reflect.package$.ToolBox(Lscala/reflect/api/JavaUniverse$JavaMirror;)Lscala/tools/reflect/ToolBoxFactory;





Aucun commentaire:

Enregistrer un commentaire