I have a scala project that compiles and can be executed without errors.
I added diameter dependency in my module's build.sbt file:
libraryDependencies ++= Seq(
// some other dependencies here
// then diameter dependencies
"org.mobicents.diameter" % "jdiameter-api" % "1.7.0.106",
"org.mobicents.diameter" % "jdiameter-impl" % "1.7.0.106"
)
The project still compiles but can't run:
[app] $ compile
[success] Total time: 1 s, completed Sep 28, 2016 2:54:36 PM
[app] $ run
SLF4J: Class path contains multiple SLF4J bindings.
--- (Running the application, auto-reloading is enabled) ---
log4j:WARN No appenders could be found for logger (akka.event.slf4j.Slf4jLogger).
log4j:WARN Please initialize the log4j system properly.
java.lang.AbstractMethodError: org.slf4j.impl.Log4jLoggerAdapter.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
at org.slf4j.bridge.SLF4JBridgeHandler.callLocationAwareLogger(SLF4JBridgeHandler.java:221)
at org.slf4j.bridge.SLF4JBridgeHandler.publish(SLF4JBridgeHandler.java:297)
at java.util.logging.Logger.log(Logger.java:738)
at java.util.logging.Logger.doLog(Logger.java:765)
at java.util.logging.Logger.logp(Logger.java:930)
at org.jboss.netty.logging.JdkLogger.debug(JdkLogger.java:36)
at org.jboss.netty.channel.socket.nio.SelectorUtil.<clinit>(SelectorUtil.java:57)
at org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory.getMaxThreads(NioServerSocketChannelFactory.java:248)
at org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory.<init>(NioServerSocketChannelFactory.java:115)
at play.core.server.NettyServer.play$core$server$NettyServer$$newBootstrap(NettyServer.scala:46)
at play.core.server.NettyServer$$anonfun$1.apply(NettyServer.scala:130)
at play.core.server.NettyServer$$anonfun$1.apply(NettyServer.scala:129)
at scala.Option.map(Option.scala:146)
at play.core.server.NettyServer.<init>(NettyServer.scala:129)
at play.core.server.NettyServerProvider.createServer(NettyServer.scala:200)
at play.core.server.NettyServerProvider.createServer(NettyServer.scala:199)
at play.core.server.DevServerStart$$anonfun$mainDev$1.apply(DevServerStart.scala:208)
at play.core.server.DevServerStart$$anonfun$mainDev$1.apply(DevServerStart.scala:61)
at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
at play.core.server.DevServerStart$.mainDev(DevServerStart.scala:60)
at play.core.server.DevServerStart$.mainDevHttpMode(DevServerStart.scala:50)
at play.core.server.DevServerStart.mainDevHttpMode(DevServerStart.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at play.runsupport.Reloader$.startDevMode(Reloader.scala:223)
at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.devModeServer$lzycompute$1(PlayRun.scala:74)
at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.play$sbt$run$PlayRun$$anonfun$$anonfun$$anonfun$$devModeServer$1(PlayRun.scala:74)
at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.apply(PlayRun.scala:100)
at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.apply(PlayRun.scala:53)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
[trace] Stack trace suppressed: run last app/compile:run for the full output.
[error] (app/compile:run) java.lang.reflect.InvocationTargetException
[error] Total time: 2 s, completed Sep 28, 2016 2:54:42 PM
I don't understand how adding those two dependencies could break the application. I can see the downloaded jars in the .ivy2 cache so the new dependencies were resolved.
How can I fix this?
The full output says:
java.lang.reflect.InvocationTargetException
Many thanks for your help
Update
If I add this dependency only
"org.mobicents.diameter" % "jdiameter-api" % "1.7.0.106"
it works :)
but I need both :(
It looks like both dependencies add their own logger implementations, and they clash at runtime.
Try excluding it from one of the two, for example:
libraryDependencies ++= Seq(
"org.mobicents.diameter" % "jdiameter-api" % "1.7.0.106",
"org.mobicents.diameter" % "jdiameter-impl" % "1.7.0.106" exclude("org.slf4j", "slf4j-jdk14")
)
Related
I'm using the sbt-native-packager to build my Docker image and publish it to my local. I have a custom directory where I have some files that I would like to be part of the resulting Docker file system. I have tried the following in my build.sbt:
Universal / mappings += (file("data/housing.tgz"), "/opt/docker/data/housing.tgz")
But this results in an error as below:
[info] welcome to sbt 1.5.7 (Private Build Java 1.8.0_312)
[info] loading settings for project housing-price-prediction-data-preparation-build from plugins.sbt ...
[info] loading project definition from /home/joesan/Projects/Private/ml-projects/housing-price-prediction-data-preparation/project
[info] loading settings for project housing-price-prediction-data-preparation from build.sbt ...
[info] resolving key references (10159 settings) ...
Reference to undefined setting:
Universal / mappings from Universal / mappings (/home/joesan/Projects/Private/ml-projects/housing-price-prediction-data-preparation/build.sbt:58)
at sbt.internal.util.Init.Uninitialized(Settings.scala:419)
at sbt.internal.util.Init.Uninitialized$(Settings.scala:406)
at sbt.Def$.Uninitialized(Def.scala:24)
at sbt.internal.util.Init.delegate(Settings.scala:313)
at sbt.internal.util.Init.delegate$(Settings.scala:275)
at sbt.Def$.delegate(Def.scala:24)
at sbt.internal.util.Init.compiled(Settings.scala:200)
at sbt.internal.util.Init.compiled$(Settings.scala:187)
at sbt.Def$.compiled(Def.scala:24)
at sbt.internal.util.Init.makeWithCompiledMap(Settings.scala:217)
at sbt.internal.util.Init.makeWithCompiledMap$(Settings.scala:212)
at sbt.Def$.makeWithCompiledMap(Def.scala:24)
at sbt.internal.Load$.$anonfun$apply$5(Load.scala:263)
at sbt.internal.Load$.timed(Load.scala:1393)
at sbt.internal.Load$.apply(Load.scala:255)
at sbt.internal.Load$.defaultLoad(Load.scala:56)
at sbt.BuiltinCommands$.liftedTree1$1(Main.scala:959)
at sbt.BuiltinCommands$.doLoadProject(Main.scala:959)
at sbt.BuiltinCommands$.$anonfun$loadProjectImpl$2(Main.scala:912)
at sbt.Command$.$anonfun$applyEffect$4(Command.scala:150)
at sbt.Command$.$anonfun$applyEffect$2(Command.scala:145)
at sbt.Command$.process(Command.scala:189)
at sbt.MainLoop$.$anonfun$processCommand$5(MainLoop.scala:245)
at scala.Option.getOrElse(Option.scala:189)
at sbt.MainLoop$.process$1(MainLoop.scala:245)
at sbt.MainLoop$.processCommand(MainLoop.scala:278)
at sbt.MainLoop$.$anonfun$next$5(MainLoop.scala:163)
at sbt.State$StateOpsImpl$.runCmd$1(State.scala:289)
at sbt.State$StateOpsImpl$.process$extension(State.scala:325)
at sbt.MainLoop$.$anonfun$next$4(MainLoop.scala:163)
at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
at sbt.MainLoop$.next(MainLoop.scala:163)
at sbt.MainLoop$.run(MainLoop.scala:144)
at sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:119)
at sbt.io.Using.apply(Using.scala:27)
at sbt.MainLoop$.runWithNewLog(MainLoop.scala:112)
at sbt.MainLoop$.runAndClearLast(MainLoop.scala:66)
at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:51)
at sbt.MainLoop$.runLogged(MainLoop.scala:42)
at sbt.StandardMain$.runManaged(Main.scala:218)
at sbt.xMain$.$anonfun$run$11(Main.scala:133)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
at scala.Console$.withIn(Console.scala:230)
at sbt.internal.util.Terminal$.withIn(Terminal.scala:569)
at sbt.internal.util.Terminal$.$anonfun$withStreams$1(Terminal.scala:350)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
at scala.Console$.withOut(Console.scala:167)
at sbt.internal.util.Terminal$.$anonfun$withOut$2(Terminal.scala:559)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
at scala.Console$.withErr(Console.scala:196)
at sbt.internal.util.Terminal$.withOut(Terminal.scala:559)
at sbt.internal.util.Terminal$.withStreams(Terminal.scala:350)
at sbt.xMain$.withStreams$1(Main.scala:87)
at sbt.xMain$.run(Main.scala:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sbt.internal.XMainConfiguration.run(XMainConfiguration.java:56)
at sbt.xMain.run(Main.scala:46)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:111)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:130)
at xsbt.boot.Launch$.run(Launch.scala:111)
at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:37)
at xsbt.boot.Launch$.launch(Launch.scala:119)
at xsbt.boot.Launch$.apply(Launch.scala:20)
at xsbt.boot.Boot$.runImpl(Boot.scala:56)
at xsbt.boot.Boot$.main(Boot.scala:18)
at xsbt.boot.Boot.main(Boot.scala)
[error] Reference to undefined setting:
[error]
[error] Universal / mappings from Universal / mappings (/home/joesan/Projects/Private/ml-projects/housing-price-prediction-data-preparation/build.sbt:58)
[error]
[error] Use 'last' for the full log.
[warn] Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? (default: r)
Isn't like this how I should be adding additional folders? What is causing this error?
My plugins.sbt has the following:
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.3")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.1.0")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3")
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.9")
I am trying to compile an old school project from around March, 2015. I haven’t touched it since then. The project is written in Scala with the Swing library, and the build tool is sbt.
Apparently my build.sbt file needs updating. After digging the Internet, I found that this configuration should work.
lazy val root = (project in file (".")).
settings (
name := "MyProgram",
/* FORMERLY: */
//libraryDependencies += "org.scala-lang" % "scala-swing" % "2.10+",
//ivyScala := ivyScala.value map { _.copy(overrideScalaVersion = true) }
/* NOW: */
scalaVersion := "2.13.0",
libraryDependencies += "org.scala-lang.modules" %% "scala-swing" % "2.1.1"
)
The trick would be to use compatible versions of Scala and Swing. I tried the following pairs, which I expected to work together (either because I saw them on the webpage of package Swing, or because it worked for other people on SO):
(Scala 2.13.0, Swing 2.1.1)
(Scala 2.12.6, Swing 2.1.1)
(Scala 2.12.1, Swing 2.0.0-M)
(Scala 2.11.1, Swing 1.0.2)
I also tried switching from Java 12 (jdk-openjdk 12.0.2.u10-1) to Java 8 (jdk8-openjdk 8.u222-2).
However, all combinations give the same error. Compiling (sbt compile) works fine, but running the application (sbt run) results in a bunch of NoClassDefFoundError / ClassNotFoundException errors:
$ sbt run
[info] Loading project definition from /home/me/MyProject/project
[info] Loading settings for project root from build.sbt ...
[info] Set current project to MyProject (in build file:/home/me/MyProject/)
[info] Compiling 22 Scala sources to /home/me/MyProject/target/scala-2.12/classes ...
[warn] there were four deprecation warnings (since 2.12.0); re-run with -deprecation for details
[warn] one warning found
[info] running Main.Main
[error] java.lang.NoClassDefFoundError: scala/swing/event/WindowOpened
[error] at scala.swing.Window$$anon$1.windowOpened(Window.scala:80)
...
[error] Caused by: java.lang.ClassNotFoundException: scala.swing.event.WindowOpened
[error] at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
...
[error] java.lang.NoClassDefFoundError: scala/swing/event/WindowActivated
[error] at scala.swing.Window$$anon$1.windowActivated(Window.scala:74)
...
[error] Caused by: java.lang.ClassNotFoundException: scala.swing.event.WindowActivated
[error] at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
...
The application’s main window shows up but is pretty unusable, with every GUI element generating more errors when activated; even trying to close the window via the window manager fails.
What is missing to run this program?
I installed IntelliJ idea community edition 14.1.3 on my windows 7 machine.
I created a simple sbt project where the build.sbt file looks like
name := "SlickTest"
version := "1.0"
scalaVersion := "2.11.6"
libraryDependencies ++= Seq(
"com.typesafe.slick" %% "slick" % "3.0.0-RC3",
"org.slf4j" % "slf4j-nop" % "1.6.4",
"com.typesafe" % "config" % "1.0.2"
)
Now I wrote a simple class
import com.typesafe.config.ConfigFactory
object Foo {
def main(args : Array[String]): Unit = {
println("foo")
val conf = ConfigFactory.load()
val foo = conf.getString("derby.url")
println(foo)
}
}
I created a file called "application.conf" in the resources folder.
derby = {
url = "foo"
}
Now if I go to command line and say sbt clean compile run I can see
D:\myapps\Scala\SlickTest>sbt clean compile run
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Loading project definition from D:\myapps\Scala\SlickTest\project
[info] Set current project to SlickTest (in build file:/D:/myapps/Scala/SlickTest/)
[success] Total time: 0 s, completed May 26, 2015 2:24:04 AM
[info] Updating {file:/D:/myapps/Scala/SlickTest/}slicktest...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[info] Compiling 1 Scala source to D:\myapps\Scala\SlickTest\target\scala-2.11\classes...
[success] Total time: 3 s, completed May 26, 2015 2:24:07 AM
[info] Running Foo
foo
foo
[success] Total time: 0 s, completed May 26, 2015 2:24:07 AM
D:\myapps\Scala\SlickTest>
but when I try to build the same project in Intellij idea I see
Error:scalac: Error: Could not find an output directory for D:\myapps\Scala\SlickTest\src\main\scala-2.11\SlickTest.scala in List((D:\myapps\scala\SlickTest\src\test\resources,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\main\resources,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\test\scala-2.11,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\test\scala,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\test\java,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\main\scala-2.11,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\main\scala,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\main\java,D:\myapps\scala\SlickTest\target\scala-2.11\classes))
scala.reflect.internal.FatalError: Could not find an output directory for D:\myapps\Scala\SlickTest\src\main\scala-2.11\SlickTest.scala in List((D:\myapps\scala\SlickTest\src\test\resources,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\main\resources,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\test\scala-2.11,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\test\scala,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\test\java,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\main\scala-2.11,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\main\scala,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\main\java,D:\myapps\scala\SlickTest\target\scala-2.11\classes))
at scala.tools.nsc.settings.MutableSettings$OutputDirs.outputDirFor(MutableSettings.scala:311)
at scala.tools.nsc.backend.jvm.BytecodeWriters$class.outputDirectory(BytecodeWriters.scala:26)
at scala.tools.nsc.backend.jvm.GenASM.outputDirectory(GenASM.scala:23)
at scala.tools.nsc.backend.jvm.BytecodeWriters$class.getFile(BytecodeWriters.scala:41)
at scala.tools.nsc.backend.jvm.GenASM.getFile(GenASM.scala:23)
at scala.tools.nsc.backend.jvm.GenASM$JBuilder.writeIfNotTooBig(GenASM.scala:531)
at scala.tools.nsc.backend.jvm.GenASM$JMirrorBuilder.genMirrorClass(GenASM.scala:2835)
at scala.tools.nsc.backend.jvm.GenASM$AsmPhase.emitFor$1(GenASM.scala:193)
at scala.tools.nsc.backend.jvm.GenASM$AsmPhase.run(GenASM.scala:203)
at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1500)
at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1487)
at scala.tools.nsc.Global$Run.compileSources(Global.scala:1482)
at scala.tools.nsc.Global$Run.compile(Global.scala:1580)
at xsbt.CachedCompiler0.run(CompilerInterface.scala:126)
at xsbt.CachedCompiler0.run(CompilerInterface.scala:102)
at xsbt.CompilerInterface.run(CompilerInterface.scala:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:102)
at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:48)
at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:41)
at org.jetbrains.jps.incremental.scala.local.IdeaIncrementalCompiler.compile(IdeaIncrementalCompiler.scala:29)
at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:26)
at org.jetbrains.jps.incremental.scala.remote.Main$.make(Main.scala:62)
at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:20)
at org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.martiansoftware.nailgun.NGSession.run(NGSession.java:319)
Does anyone know why can't IntelliJ build the same project when sbt can easily build it.
I searched for couple of could not find output directory threads but they did not help me because unlike others I don't have a capitalization error in my path or project name.
Open Project settings and fill up the input with output path for this project, as on the image below.
I am trying to run findbugs-sbt plugin (https://bitbucket.org/jmhofer/findbugs4sbt/wiki/Home) for my project. However I got this error when trying to run findbugs in sbt console
[error] Exception in thread "main" java.lang.NoClassDefFoundError: edu/umd/cs/findbugs/LaunchAppropriateUI
[error] Caused by: java.lang.ClassNotFoundException: edu.umd.cs.findbugs.LaunchAppropriateUI
[error] at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
[error] at java.security.AccessController.doPrivileged(Native Method)
[error] at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[error] at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
[error] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
[error] at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
[error] Could not find the main class: edu.umd.cs.findbugs.LaunchAppropriateUI. Program will exit.
in project/Build.scala, I just include this as described in their wiki
import de.johoop.findbugs4sbt.FindBugs._
lazy val foo = Project(..., settings = ... ++ findbugsSettings)
in project/plugins.sbt, I added this
addSbtPlugin("de.johoop" % "findbugs4sbt" % "1.2.0") // because I am using sbt 0.12
I tried to add the findbugs dependency in project/plugins.sbt
libraryDependencies ++= Seq(
"com.google.code.findbugs" % "findbugs" % "2.0.1")
but still no go.
After looking at the source code of this plugin, I found out I had to specify the findbugs classpath to make the sbt action work. For those who run into the same problem, here is the solution.
findbugsClasspath := IO.listFiles(file(<your findbugs lib location>)).filter(_.getName.endsWith("jar")).toSeq.classpath
This should've been pointed out clearly in the wiki.
BTW - I believe this could also solve the similar issue by the cpd sbt plugin.
I have this multi-module build configuration that I'm trying to get working, but whenever I try to compile the project it fails with the following error:
➜ postgresql-netty git:(multi-module) sbt clean compile
[info] Loading global plugins from /Users/mauricio/.sbt/plugins
[info] Loading project definition from /Users/mauricio/projects/scala/postgresql-netty/project
[info] Set current project to db-async-base (in build file:/Users/mauricio/projects/scala/postgresql-netty/)
[success] Total time: 0 s, completed May 1, 2013 11:18:29 PM
[info] Updating {file:/Users/mauricio/projects/scala/postgresql-netty/}db-async-common...
[info] Updating {file:/Users/mauricio/projects/scala/postgresql-netty/}db-async-base...
[info] Resolving org.specs2#scalaz-core_2.10;7.0.0 ...
[info] Done updating.
[info] Resolving org.scala-lang#scala-library;2.10.1 ...
[info] Done updating.
[info] Updating {file:/Users/mauricio/projects/scala/postgresql-netty/}postgresql-async...
[info] Resolving ch.qos.logback#logback-classic;1.0.9 ...
[info] Compiling 16 Scala sources to /Users/mauricio/projects/scala/postgresql-netty/db-async-common/target/scala-2.10/classes...
[info] Resolving org.specs2#scalaz-core_2.10;7.0.0 ...
[info] Done updating.
scala.reflect.internal.MissingRequirementError: object scala.runtime in compiler mirror not found.
at scala.reflect.internal.MissingRequirementError$.signal(MissingRequirementError.scala:16)
at scala.reflect.internal.MissingRequirementError$.notFound(MissingRequirementError.scala:17)
at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:48)
at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:40)
at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:61)
at scala.reflect.internal.Mirrors$RootsBase.getPackage(Mirrors.scala:172)
at scala.reflect.internal.Mirrors$RootsBase.getRequiredPackage(Mirrors.scala:175)
at scala.reflect.internal.Definitions$DefinitionsClass.RuntimePackage$lzycompute(Definitions.scala:181)
at scala.reflect.internal.Definitions$DefinitionsClass.RuntimePackage(Definitions.scala:181)
at scala.reflect.internal.Definitions$DefinitionsClass.RuntimePackageClass$lzycompute(Definitions.scala:182)
at scala.reflect.internal.Definitions$DefinitionsClass.RuntimePackageClass(Definitions.scala:182)
at scala.reflect.internal.Definitions$DefinitionsClass.AnnotationDefaultAttr$lzycompute(Definitions.scala:1015)
at scala.reflect.internal.Definitions$DefinitionsClass.AnnotationDefaultAttr(Definitions.scala:1014)
at scala.reflect.internal.Definitions$DefinitionsClass.syntheticCoreClasses$lzycompute(Definitions.scala:1144)
at scala.reflect.internal.Definitions$DefinitionsClass.syntheticCoreClasses(Definitions.scala:1143)
at scala.reflect.internal.Definitions$DefinitionsClass.symbolsNotPresentInBytecode$lzycompute(Definitions.scala:1187)
at scala.reflect.internal.Definitions$DefinitionsClass.symbolsNotPresentInBytecode(Definitions.scala:1187)
at scala.reflect.internal.Definitions$DefinitionsClass.init(Definitions.scala:1252)
at scala.tools.nsc.Global$Run.<init>(Global.scala:1289)
at xsbt.CachedCompiler0.run(CompilerInterface.scala:87)
at xsbt.CachedCompiler0.run(CompilerInterface.scala:72)
at xsbt.CompilerInterface.run(CompilerInterface.scala:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:73)
at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:35)
at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:29)
at sbt.compiler.AggressiveCompile$$anonfun$4$$anonfun$compileScala$1$1.apply$mcV$sp(AggressiveCompile.scala:71)
at sbt.compiler.AggressiveCompile$$anonfun$4$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:71)
at sbt.compiler.AggressiveCompile$$anonfun$4$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:71)
at sbt.compiler.AggressiveCompile.sbt$compiler$AggressiveCompile$$timed(AggressiveCompile.scala:101)
at sbt.compiler.AggressiveCompile$$anonfun$4.compileScala$1(AggressiveCompile.scala:70)
at sbt.compiler.AggressiveCompile$$anonfun$4.apply(AggressiveCompile.scala:88)
at sbt.compiler.AggressiveCompile$$anonfun$4.apply(AggressiveCompile.scala:60)
at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:24)
at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:22)
at sbt.inc.Incremental$.cycle(Incremental.scala:52)
at sbt.inc.Incremental$.compile(Incremental.scala:29)
at sbt.inc.IncrementalCompile$.apply(Compile.scala:20)
at sbt.compiler.AggressiveCompile.compile2(AggressiveCompile.scala:96)
at sbt.compiler.AggressiveCompile.compile1(AggressiveCompile.scala:44)
at sbt.compiler.AggressiveCompile.apply(AggressiveCompile.scala:31)
at sbt.Compiler$.apply(Compiler.scala:79)
at sbt.Defaults$$anonfun$compileTask$1.apply(Defaults.scala:574)
at sbt.Defaults$$anonfun$compileTask$1.apply(Defaults.scala:574)
at sbt.Scoped$$anonfun$hf2$1.apply(Structure.scala:578)
at sbt.Scoped$$anonfun$hf2$1.apply(Structure.scala:578)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:49)
at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$12.apply(Structure.scala:311)
at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$12.apply(Structure.scala:311)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:41)
at sbt.std.Transform$$anon$5.work(System.scala:71)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:232)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:232)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
at sbt.Execute.work(Execute.scala:238)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:232)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:232)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
[error] (db-async-common/compile:compile) scala.reflect.internal.MissingRequirementError: object scala.runtime in compiler mirror not found.
[error] Total time: 4 s, completed May 1, 2013 11:18:33 PM
Any idea what this is and how can I fix it?
The issue is when you clear all the project dependencies up while setting yours, i.e. using := not ++= or += to add dependencies to libraryDependencies in a build definition, say in build.sbt:
libraryDependencies := Dependencies.microservice
With := all the current dependencies that sbt sets upfront in libraryDependencies are cleared out and the only available dependencies are these from Dependencies.microservice (as in the above example).
Adding up "org.scala-lang" % "scala-library" % "2.10.1" (or whatever version of scalaVersion you use) is just a workaround for clearing out the already-properly-initialized libraryDependencies setting.
It's easily to reproduce with the following build definition - build.sbt:
libraryDependencies := Seq()
Trying to compile Scala files results in the error - note show libraryDependencies:
➜ clear-library-dependencies xsbt
JAVA_HOME=/Library/Java/JavaVirtualMachines/java8/Contents/Home
SBT_OPTS= -Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -Dfile.encoding=UTF-8
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Updating {file:/Users/jacek/.sbt/0.13/plugins/}global-plugins...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to clear-library-dependencies (in build file:/Users/jacek/dev/sandbox/clear-library-dependencies/)
[clear-library-dependencies]> show libraryDependencies
[info] List()
[clear-library-dependencies]> compile
[info] Updating {file:/Users/jacek/dev/sandbox/clear-library-dependencies/}clear-library-dependencies...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Compiling 1 Scala source to /Users/jacek/dev/sandbox/clear-library-dependencies/target/scala-2.10/classes...
[trace] Stack trace suppressed: run last compile:compileIncremental for the full output.
[error] (compile:compileIncremental) scala.reflect.internal.MissingRequirementError: object scala.runtime in compiler mirror not found.
[error] Total time: 0 s, completed Feb 3, 2015 10:36:08 PM
Change the build to the following (not usable, but just to show the point):
libraryDependencies ++= Seq()
The result's going to be as follows:
[clear-library-dependencies]> reload
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Set current project to clear-library-dependencies (in build file:/Users/jacek/dev/sandbox/clear-library-dependencies/)
[clear-library-dependencies]> show libraryDependencies
[info] List(org.scala-lang:scala-library:2.10.4)
[clear-library-dependencies]> compile
[info] Updating {file:/Users/jacek/dev/sandbox/clear-library-dependencies/}clear-library-dependencies...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Compiling 1 Scala source to /Users/jacek/dev/sandbox/clear-library-dependencies/target/scala-2.10/classes...
[success] Total time: 1 s, completed Feb 3, 2015 10:38:19 PM
Adding scala-library as a project dependency:
"org.scala-lang" % "scala-library" % "2.10.1"
Did the trick. Still not sure why this is necessary now but wasn't before.
The thing that ended up alleviating this error for me was downgrading my java version. I recently upgraded to Java 10 which seems to have compatibility issues with some versions of scala (at the very least it has problems with scala 2.12), so moving down to Java 8 did the trick.
FWIW, I had a similar issue that resolved itself when I removed the .ivy2 cache for scala and restarted sbt.