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.
Related
The basic Play Framework sample (play-scala-hello-world-tutorial) fails on Ubuntu 20 with OpenAdopt JDK but works fine on Macos. Is there something arry with my Linux setup?
Per https://www.playframework.com/getting-started) I...
> git clone https://github.com/playframework/play-samples.git
> cd play-samples/play-scala-hello-world-tutorial
> sbt run
[info] welcome to sbt 1.4.3 (AdoptOpenJDK Java 16)
[info] loading global plugins from /home/gp/.sbt/1.0/plugins
[info] loading settings for project play-scala-hello-world-tutorial-build from plugins.sbt,scaffold.sbt ...
[info] loading project definition from /home/.../play-samples/play-scala-hello-world-tutorial/project
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] loading settings for project root from build.sbt ...
[info] set current project to play-scala-hello-world-tutorial (in build file:/home/.../play-samples/play-scala-hello-world-tutorial/)
--- (Running the application, auto-reloading is enabled) ---
[info] p.c.s.AkkaHttpServer - Listening for HTTP on /[0:0:0:0:0:0:0:0]:9000
(Server started, use Enter to stop and go back to the console...)
curl localhost:9000
results in this:
play.api.UnexpectedException: Unexpected exception[UncheckedExecutionException: java.lang.IllegalStateException: Unable to load cache item]
at play.core.server.DevServerStart$$anon$1.reload(DevServerStart.scala:254)
at play.core.server.DevServerStart$$anon$1.get(DevServerStart.scala:148)
at play.core.server.AkkaHttpServer.handleRequest(AkkaHttpServer.scala:302)
at play.core.server.AkkaHttpServer.$anonfun$createServerBinding$1(AkkaHttpServer.scala:224)
at akka.stream.impl.fusing.MapAsync$$anon$30.onPush(Ops.scala:1297)
at akka.stream.impl.fusing.GraphInterpreter.processPush(GraphInterpreter.scala:541)
at akka.stream.impl.fusing.GraphInterpreter.processEvent(GraphInterpreter.scala:495)
at akka.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:390)
at akka.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:625)
at akka.stream.impl.fusing.GraphInterpreterShell$AsyncInput.execute(ActorGraphInterpreter.scala:502)
Caused by: com.google.common.util.concurrent.UncheckedExecutionException: java.lang.IllegalStateException: Unable to load cache item
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2051)
at com.google.common.cache.LocalCache.get(LocalCache.java:3951)
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3974)
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4958)
at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4964)
at com.google.inject.internal.FailableCache.get(FailableCache.java:54)
at com.google.inject.internal.ConstructorInjectorStore.get(ConstructorInjectorStore.java:49)
at com.google.inject.internal.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:155)
at com.google.inject.internal.InjectorImpl.initializeBinding(InjectorImpl.java:592)
at com.google.inject.internal.AbstractBindingProcessor$Processor.initializeBinding(AbstractBindingProcessor.java:173)
Caused by: java.lang.IllegalStateException: Unable to load cache item
at com.google.inject.internal.cglib.core.internal.$LoadingCache.createEntry(LoadingCache.java:79)
at com.google.inject.internal.cglib.core.internal.$LoadingCache.get(LoadingCache.java:34)
at com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:119)
at com.google.inject.internal.cglib.core.$AbstractClassGenerator.create(AbstractClassGenerator.java:294)
at com.google.inject.internal.cglib.reflect.$FastClass$Generator.create(FastClass.java:65)
at com.google.inject.internal.BytecodeGen.newFastClassForMember(BytecodeGen.java:258)
at com.google.inject.internal.BytecodeGen.newFastClassForMember(BytecodeGen.java:207)
at com.google.inject.internal.DefaultConstructionProxyFactory.create(DefaultConstructionProxyFactory.java:49)
at com.google.inject.internal.ProxyFactory.create(ProxyFactory.java:156)
at com.google.inject.internal.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:94)
Caused by: java.lang.ExceptionInInitializerError: null
at com.google.inject.internal.cglib.core.$DuplicatesPredicate.evaluate(DuplicatesPredicate.java:104)
at com.google.inject.internal.cglib.core.$CollectionUtils.filter(CollectionUtils.java:52)
at com.google.inject.internal.cglib.reflect.$FastClassEmitter.<init>(FastClassEmitter.java:69)
at com.google.inject.internal.cglib.reflect.$FastClass$Generator.generateClass(FastClass.java:77)
at com.google.inject.internal.cglib.core.$DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
at com.google.inject.internal.cglib.core.$AbstractClassGenerator.generate(AbstractClassGenerator.java:332)
at com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:96)
at com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:94)
at com.google.inject.internal.cglib.core.internal.$LoadingCache$2.call(LoadingCache.java:54)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
Caused by: com.google.inject.internal.cglib.core.$CodeGenerationException: java.lang.reflect.InaccessibleObjectException-->Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module #5f574e3d
at com.google.inject.internal.cglib.core.$ReflectUtils.defineClass(ReflectUtils.java:464)
at com.google.inject.internal.cglib.core.$AbstractClassGenerator.generate(AbstractClassGenerator.java:339)
at com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:96)
at com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:94)
at com.google.inject.internal.cglib.core.internal.$LoadingCache$2.call(LoadingCache.java:54)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at com.google.inject.internal.cglib.core.internal.$LoadingCache.createEntry(LoadingCache.java:61)
at com.google.inject.internal.cglib.core.internal.$LoadingCache.get(LoadingCache.java:34)
at com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:119)
at com.google.inject.internal.cglib.core.$AbstractClassGenerator.create(AbstractClassGenerator.java:294)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module #5f574e3d
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
at com.google.inject.internal.cglib.core.$ReflectUtils$1.run(ReflectUtils.java:61)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:554)
at com.google.inject.internal.cglib.core.$ReflectUtils.<clinit>(ReflectUtils.java:52)
at com.google.inject.internal.cglib.reflect.$FastClassEmitter.<init>(FastClassEmitter.java:67)
at com.google.inject.internal.cglib.reflect.$FastClass$Generator.generateClass(FastClass.java:77)
at com.google.inject.internal.cglib.core.$DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
>java -version
openjdk version "16" 2021-03-16
OpenJDK Runtime Environment AdoptOpenJDK (build 16+36)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 16+36, mixed mode, sharing)
> sbt sbtVersion
[info] welcome to sbt 1.3.13 (AdoptOpenJDK Java 16)
[info] loading global plugins from /home/../.sbt/1.0/plugins
[info] loading settings for project play-scala-hello-world-tutorial-build from scaffold.sbt,plugins.sbt ...
[info] loading project definition from /home/.../play-samples/play-scala-hello-world-tutorial/project
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] loading settings for project root from build.sbt ...
[info] set current project to play-scala-hello-world-tutorial (in build file:/home/.../play-samples/play-scala-hello-world-tutorial/)
[info] 1.3.13
project/build.properties:
# sbt.version=1.3.13
sbt.version=1.4.3
I was having the same issue with JDK-11
Trying with Java8 solved the issue.
For me is the opposite of #ProofJS's solution. On Windows 10,
JDK8 would not work (it would not compile - sbt compile). JDK 11 worked without problems. JDK 17 did compile, but would not run - sbt run.
welcome to sbt 1.3.13 (Oracle Corporation Java 11.0.12)
In IntelliJ, in the context menu for the project (right click) -> Open Module Settings -> Project -> SDK 11.0.12.
build.properties (file):
sbt.version=1.3.13
plugins.sbt (file):
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.11")
build.sbt (file):
lazy val root = (project in file("."))
.enablePlugins(PlayScala)
.settings(
name := """play-scala-forms-example""",
version := "2.8.x",
scalaVersion := "2.13.7",
libraryDependencies ++= Seq(
guice,
"org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" % Test,
),
scalacOptions ++= Seq(
"-feature",
"-deprecation",
"-Xfatal-warnings"
)
)
System Env: JAVA_HOME & Path set to JDK-11/bin
Play 2.8.16 is dependent on google Guice version 4.2.3, which only support jdk 14, to make this run with java 17, you need to add the following code snippet into your build.sbt
dependencyOverrides ++= Seq(
"com.google.inject" % "guice" % "5.1.0",
"com.google.inject.extensions" % "guice-assistedinject" % "5.1.0")
Here are few links you can have a look :-
https://github.com/google/guice/wiki/Guice423
https://github.com/google/guice/wiki/Guice510
https://github.com/playframework/playframework/releases/2.8.15
Adding the above snippet code would make it able to run with 17.
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 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")
)
I have an unmanagedClasspath entry in my lift sbt file that points to the classes for an external java project. It compiles fine but I get a NoClassDefError when it runs. Below is the sbt entry followed by some of the trace of the NoClassDefError.
Any help much appreciated
Des
unmanagedClasspath in Compile += file("[Path to my project]/classes")
ERROR n.liftweb.http.provider.HTTPProvider - Failed to Boot! Your application may not run properly
java.lang.NoClassDefFoundError: com/myproject/MyClass
at bootstrap.liftweb.Boot.boot(Boot.scala:70) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_21]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_21]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_21]
at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_21]
at net.liftweb.util.ClassHelpers$$anonfun$createInvoker$1.apply(ClassHelpers.scala:364) ~[lift-util_2.9.1-2.5-RC2.jar:2.5-RC2]
at net.liftweb.util.ClassHelpers$$anonfun$createInvoker$1.apply(ClassHelpers.scala:362) ~[lift-util_2.9.1-2.5-RC2.jar:2.5-RC2]
at net.liftweb.http.DefaultBootstrap$$anonfun$boot$1.apply(LiftRules.scala:1999) ~[lift-webkit_2.9.1-2.5-RC2.jar:2.5-RC2]
at net.liftweb.http.DefaultBootstrap$$anonfun$boot$1.apply(LiftRules.scala:1999) ~[lift-webkit_2.9.1-2.5-RC2.jar:2.5-RC2]
at net.liftweb.common.Full.map(Box.scala:553) ~[lift-common_2.9.1-2.5-RC2.jar:2.5-RC2]
unmanagedJars in Compile is used as base for the same key in Runtime and Test, so its content is inherited by Runtime, but this is not the case for unmanagedClasspath. That's why you should prefer unmanagedJars when possible.
You can explicitly add your folder to both configurations:
val additionalClasses = file("[Path to my project]/classes")
unmanagedClasspath in Compile += additionalClasses
unmanagedClasspath in Runtime += additionalClasses
Note: sbt < 0.13 doesn't support val in build.sbt, so you have to duplicate its content in both settings, or switch to a full Build.scala.
See the Classpaths docs and this anwser for more details on what the classpath settings do and how they are inherited between configurations.
I could not think of a way to add it to both at the same time though...
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.