I am trying to run Scala tests (specs2) in Intellij Coummunity Edition 13.1.3. I am getting the following error:
Connected to the target VM, address: '127.0.0.1:57980', transport: 'socket'
'Start' method is not found in MyNotifierRunner null
Exception in thread "main" java.lang.reflect.InvocationTargetException
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:606)
Disconnected from the target VM, address: '127.0.0.1:57980', transport: 'socket'
at org.jetbrains.plugins.scala.testingSupport.specs2.JavaSpecs2Runner.runSingleTest(JavaSpecs2Runner.java:123)
at org.jetbrains.plugins.scala.testingSupport.specs2.JavaSpecs2Runner.main(JavaSpecs2Runner.java:69)
Caused by: java.lang.NoSuchMethodError: org.specs2.matcher.MatchResult$.matchResultAsResult()Lorg/specs2/execute/AsResult;
at components.reports.ReportsDemographicsComponentTest$$anonfun$1.apply$mcV$sp(ReportsDemographicsComponentTest.scala:14)
at components.reports.ReportsDemographicsComponentTest$$anonfun$1.apply(ReportsDemographicsComponentTest.scala:13)
at components.reports.ReportsDemographicsComponentTest$$anonfun$1.apply(ReportsDemographicsComponentTest.scala:13)
at org.specs2.mutable.SideEffectingCreationPaths$$anonfun$executeBlock$1.apply$mcV$sp(FragmentsBuilder.scala:292)
at org.specs2.mutable.SideEffectingCreationPaths$class.replay(FragmentsBuilder.scala:264)
at org.specs2.mutable.Specification.replay(Specification.scala:12)
at org.specs2.mutable.FragmentsBuilder$class.fragments(FragmentsBuilder.scala:27)
at org.specs2.mutable.Specification.fragments(Specification.scala:12)
at org.specs2.mutable.SpecificationLike$class.is(Specification.scala:14)
at org.specs2.mutable.Specification.is(Specification.scala:12)
at org.specs2.specification.SpecificationStructure$$anonfun$content$1.apply(BaseSpecification.scala:56)
at org.specs2.specification.SpecificationStructure$$anonfun$content$1.apply(BaseSpecification.scala:56)
at org.specs2.specification.SpecificationStructure$class.map(BaseSpecification.scala:44)
at org.specs2.mutable.Specification.map(Specification.scala:12)
at org.specs2.specification.SpecificationStructure$class.content(BaseSpecification.scala:56)
at org.specs2.mutable.Specification.content$lzycompute(Specification.scala:12)
at org.specs2.mutable.Specification.content(Specification.scala:12)
at org.specs2.runner.ClassRunner$$anonfun$apply$1$$anonfun$apply$2.apply(ClassRunner.scala:54)
at org.specs2.runner.ClassRunner$$anonfun$apply$1$$anonfun$apply$2.apply(ClassRunner.scala:54)
at org.specs2.control.Exceptions$class.tryo(Exceptions.scala:32)
at org.specs2.control.Exceptions$.tryo(Exceptions.scala:109)
at org.specs2.runner.ClassRunner$$anonfun$apply$1.apply(ClassRunner.scala:54)
at org.specs2.runner.ClassRunner$$anonfun$apply$1.apply(ClassRunner.scala:53)
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251)
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251)
at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:34)
at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:251)
at scala.collection.AbstractTraversable.flatMap(Traversable.scala:105)
at org.specs2.runner.ClassRunner.apply(ClassRunner.scala:53)
at org.specs2.runner.ClassRunner.start(ClassRunner.scala:31)
at org.specs2.runner.ClassRunner.main(ClassRunner.scala:24)
at org.specs2.runner.NotifierRunner.main(NotifierRunner.scala:24)
... 6 more
Process finished with exit code 1
Here is piece of code runnig in sbt, but failing in Intellij:
class ReportsDemographicsComponentTest extends Specification with ReportsComponents {
"ReportsDemographicsComponent" should {
s"return empty list of $DeviceStatistics for an inexistent deliveryId" in DBUnitTestsUtils(2) {
accountId => implicit session =>
val service = new ReportsDemographicsService(accountId)
val res = service.deviceStatistics(-1)
res.size mustEqual 0
}
}
I have tried restarting Intellij, sbt, cleaning project, but to nu success. When running tests from the sbt command line, everything is OK.
In my case closing Idea and regenerating the projec setup by issuing
sbt gen-idea
Note:
You have to put this line into project/plugins.sbt to have the command:
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")
Related
I'm pretty new to Scala and I'm trying to create a notebook to elaborate data written in an Azure Event Hub. This is my code:
import org.apache.spark.eventhubs._
val connectionString = ConnectionStringBuilder("MY-CONNECTION-STRING")
.setEventHubName("EVENT-HUB-NAME")
.build
val eventHubsConf = EventHubsConf(connectionString)
.setStartingPosition(EventPosition.fromEndOfStream)
val eventhubs = spark.readStream
.format("eventhubs")
.options(eventHubsConf.toMap)
.load()
And I get the following error: java.lang.NoClassDefFoundError: Could not initialize class org.apache.spark.eventhubs.EventHubsConf$
Cluster Configuration:
Databricks Runtime Version: 7.0 (includes Apache Spark 3.0.0, Scala 2.12)
Driver & Worker Type: 14.0 GB Memory, 4 Cores, 0.75 DBU
Standard_DS3_v2
I have installed the following library:
com.microsoft.azure:azure-eventhubs-spark_2.11:2.3.17
cluster libraries
The other JAR installed is to resolve a problem with Logging
The code crashes as soon as I try to create eventHubsConf.
Complete traceback:
java.lang.NoClassDefFoundError: Could not initialize class org.apache.spark.eventhubs.EventHubsConf$
at line14a6ae940dd14957b7172a4cf8f6cdd348.$read$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$iw.<init>(command-2632683088190841:7)
at line14a6ae940dd14957b7172a4cf8f6cdd348.$read$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$iw.<init>(command-2632683088190841:70)
at line14a6ae940dd14957b7172a4cf8f6cdd348.$read$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$iw.<init>(command-2632683088190841:72)
at line14a6ae940dd14957b7172a4cf8f6cdd348.$read$$iw$$iw$$iw$$iw$$iw$$iw$$iw.<init>(command-2632683088190841:74)
at line14a6ae940dd14957b7172a4cf8f6cdd348.$read$$iw$$iw$$iw$$iw$$iw$$iw.<init>(command-2632683088190841:76)
at line14a6ae940dd14957b7172a4cf8f6cdd348.$read$$iw$$iw$$iw$$iw$$iw.<init>(command-2632683088190841:78)
at line14a6ae940dd14957b7172a4cf8f6cdd348.$read$$iw$$iw$$iw$$iw.<init>(command-2632683088190841:80)
at line14a6ae940dd14957b7172a4cf8f6cdd348.$read$$iw$$iw$$iw.<init>(command-2632683088190841:82)
at line14a6ae940dd14957b7172a4cf8f6cdd348.$read$$iw$$iw.<init>(command-2632683088190841:84)
at line14a6ae940dd14957b7172a4cf8f6cdd348.$read$$iw.<init>(command-2632683088190841:86)
at line14a6ae940dd14957b7172a4cf8f6cdd348.$read.<init>(command-2632683088190841:88)
at line14a6ae940dd14957b7172a4cf8f6cdd348.$read$.<init>(command-2632683088190841:92)
at line14a6ae940dd14957b7172a4cf8f6cdd348.$read$.<clinit>(command-2632683088190841)
at line14a6ae940dd14957b7172a4cf8f6cdd348.$eval$.$print$lzycompute(<notebook>:7)
at line14a6ae940dd14957b7172a4cf8f6cdd348.$eval$.$print(<notebook>:6)
at line14a6ae940dd14957b7172a4cf8f6cdd348.$eval.$print(<notebook>)
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 scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:745)
at scala.tools.nsc.interpreter.IMain$Request.loadAndRun(IMain.scala:1021)
at scala.tools.nsc.interpreter.IMain.$anonfun$interpret$1(IMain.scala:574)
at scala.reflect.internal.util.ScalaClassLoader.asContext(ScalaClassLoader.scala:41)
at es Scala 2.12 but yoscala.reflect.internal.util.ScalaClassLoader.asContext$(ScalaClassLoader.scala:37)
at scala.reflect.internal.util.AbstractFileClassLoader.asContext(AbstractFileClassLoader.scala:41)
at scala.tools.nsc.interpreter.IMain.loadAndRunReq$1(IMain.scala:573)
at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:600)
at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:570)
at com.databricks.backend.daemon.driver.DriverILoop.execute(DriverILoop.scala:215)
at com.databricks.backend.daemon.driver.ScalaDriverLocal.$anonfun$repl$1(ScalaDriverLocal.scala:202)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
at com.databricks.backend.daemon.driver.DriverLocal$TrapExitInternal$.trapExit(DriverLocal.scala:714)
at com.databricks.backend.daemon.driver.DriverLocal$TrapExit$.apply(DriverLocal.scala:667)
at com.databricks.backend.daemon.driver.ScalaDriverLocal.repl(ScalaDriverLocal.scala:202)
at com.databricks.backend.daemon.driver.DriverLocal.$anonfun$execute$10(DriverLocal.scala:396)
at com.databricks.logging.UsageLogging.$anonfun$withAttributionContext$1(UsageLogging.scala:238)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
at com.databricks.logging.UsageLogging.withAttributionContext(UsageLogging.scala:233)
at com.databricks.logging.UsageLogging.withAttributionContext$(UsageLogging.scala:230)
at com.databricks.backend.daemon.driver.DriverLocal.withAttributionContext(DriverLocal.scala:49)
at com.databricks.logging.UsageLogging.withAttributionTags(UsageLogging.scala:275)
at com.databricks.logging.UsageLogging.withAttributionTags$(UsageLogging.scala:268)
at com.databricks.backend.daemon.driver.DriverLocal.withAttributionTags(DriverLocal.scala:49)
at com.databricks.backend.daemon.driver.DriverLocal.execute(DriverLocal.scala:373)
at com.databricks.backend.daemon.driver.DriverWrapper.$anonfun$tryExecutingCommand$1(DriverWrapper.scala:653)
at scala.util.Try$.apply(Try.scala:213)
at com.databricks.backend.daemon.driver.DriverWrapper.tryExecutingCommand(DriverWrapper.scala:645)
at com.databricks.backend.daemon.driver.DriverWrapper.getCommandOutputAndError(DriverWrapper.scala:486)
at com.databricks.backend.daemon.driver.DriverWrapper.executeCommand(DriverWrapper.scala:598)
at com.databricks.backend.daemon.driver.DriverWrapper.runInnerLoop(DriverWrapper.scala:391)
at com.databricks.backend.daemon.driver.DriverWrapper.runInner(DriverWrapper.scala:337)
at com.databricks.backend.daemon.driver.DriverWrapper.run(DriverWrapper.scala:219)
at java.lang.Thread.run(Thread.java:748)
It seems that your Runtime includes Scala 2.12 but your package is from scala 2.11
Try installing this one
com.microsoft.azure:azure-eventhubs-spark_2.12:2.3.17
I have a issue with my really simple project in Scala:
Error:scalac: Error: Could not initialize class com.sun.jna.platform.win32.WinBase$FILETIME
java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.platform.win32.WinBase$FILETIME
at sbt.internal.io.WinMilli$.toNative(Milli.scala:310)
at sbt.internal.io.WinMilli$.toNative(Milli.scala:259)
at sbt.internal.io.MilliNative.setModifiedTime(Milli.scala:68)
at sbt.internal.io.Milli$.setModifiedTime(Milli.scala:354)
at sbt.io.IO$.setModifiedTimeOrFalse(IO.scala:1234)
at sbt.io.IO$.next$1(IO.scala:309)
at sbt.io.IO$.extract(IO.scala:317)
at sbt.io.IO$.$anonfun$unzipStream$1(IO.scala:281)
at sbt.io.Using.apply(Using.scala:22)
at sbt.io.IO$.unzipStream(IO.scala:281)
at sbt.io.IO$.$anonfun$unzip$1(IO.scala:264)
at sbt.io.Using.apply(Using.scala:22)
at sbt.io.IO$.unzip(IO.scala:264)
at sbt.internal.inc.AnalyzingCompiler$.$anonfun$compileSources$3(AnalyzingCompiler.scala:338)
at scala.collection.LinearSeqOptimized.foldLeft(LinearSeqOptimized.scala:126)
at scala.collection.LinearSeqOptimized.foldLeft$(LinearSeqOptimized.scala:122)
at scala.collection.immutable.List.foldLeft(List.scala:89)
at scala.collection.TraversableOnce.$div$colon(TraversableOnce.scala:154)
at scala.collection.TraversableOnce.$div$colon$(TraversableOnce.scala:154)
at scala.collection.AbstractTraversable.$div$colon(Traversable.scala:108)
at sbt.internal.inc.AnalyzingCompiler$.$anonfun$compileSources$2(AnalyzingCompiler.scala:337)
at sbt.internal.inc.AnalyzingCompiler$.$anonfun$compileSources$2$adapted(AnalyzingCompiler.scala:335)
at sbt.io.IO$.withTemporaryDirectory(IO.scala:376)
at sbt.io.IO$.withTemporaryDirectory(IO.scala:383)
at sbt.internal.inc.AnalyzingCompiler$.compileSources(AnalyzingCompiler.scala:335)
at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl$.org$jetbrains$jps$incremental$scala$local$CompilerFactoryImpl$$getOrCompileInterfaceJar(CompilerFactoryImpl.scala:123)
at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl.$anonfun$getScalac$1(CompilerFactoryImpl.scala:55)
at scala.Option.map(Option.scala:163)
at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl.getScalac(CompilerFactoryImpl.scala:47)
at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl.createCompiler(CompilerFactoryImpl.scala:25)
at org.jetbrains.jps.incremental.scala.local.CachingFactory.$anonfun$createCompiler$3(CachingFactory.scala:24)
at org.jetbrains.jps.incremental.scala.local.Cache.$anonfun$getOrUpdate$2(Cache.scala:20)
at scala.Option.getOrElse(Option.scala:138)
at org.jetbrains.jps.incremental.scala.local.Cache.getOrUpdate(Cache.scala:19)
at org.jetbrains.jps.incremental.scala.local.CachingFactory.createCompiler(CachingFactory.scala:24)
at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:34)
at org.jetbrains.jps.incremental.scala.remote.Main$.compileLogic(Main.scala:117)
at org.jetbrains.jps.incremental.scala.remote.Main$.handleCommand(Main.scala:109)
at org.jetbrains.jps.incremental.scala.remote.Main$.serverLogic(Main.scala:95)
at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:53)
at org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.martiansoftware.nailgun.NGSession.run(NGSession.java:319)
Here you can find code:
object Task1 {
def main(args: Array[String]) {
val dayOfWeeks = List("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")
for (e <- dayOfWeeks) println(e + ";")
}
}
Do you have any idea? I tried to uninstall the plugin and rebuild the project but nothing. I installed plugin property and will try with first project in Scala but I faced this error code.
I found the solution after many trials and errors. You need to run the development environment (in my case Intellij) as an administrator. After that you need to re-create or rebuild the project and everything should be fine.
I am a newbie to Skinny ORM and I am having a strange problem.
I am trying to get a small snippet working, SBT compiles my code but
I get a run time error message class not found. ( I get the message while
running via Intellij)
My build.sbt:
name := "skinny_jdbc"
version := "1.0"
scalaVersion := "2.12.1"
libraryDependencies ++= Seq(
"org.skinny-framework" %% "skinny-orm" % "2.3.2",
"com.h2database" % "h2" % "1.4.+",
"ch.qos.logback" % "logback-classic" % "1.1.+"
)
My test application:
import scalikejdbc._
import skinny.orm._, feature._
import org.joda.time._
object sk_test extends App{
println ("In SK_test object")
skinny.DBSettings.initialize()
implicit val session = AutoSession
}
It compiles fine - but I get a runtime error
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/pool/ObjectPool
Detailed message is below.
Thanks in Advance.
"C:\Program Files\Java\jdk1.8.0_66\bin\java" -Didea.launcher.port=7534 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2016.3\bin" -Dfile.encoding=UTF-8
-classpath "C:\Program Files\Java\jdk1.8.0_66\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_66\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_66\jre\lib\ext\access-bridge-64.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\ext\cldrdata.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\ext\dnsns.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\ext\jaccess.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\ext\jfxrt.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\ext\localedata.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_66\jre\lib\ext\sunec.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\ext\sunjce_provider.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\ext\sunmscapi.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_66\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_66\jre\lib\javaws.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\jce.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\jfr.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_66\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_66\jre\lib\management-agent.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\plugin.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\resources.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\rt.jar;C:\Users\alpha\Desktop\Coursera\skinny_jdbc\target\scala-2.12\classes;C:\Users\alpha\.ivy2\cache\org.apache.commons\commons-pool2\jars\commons-pool2-2.4.2.jar;C:\Users\alpha\.ivy2\cache\org.skinny-framework\skinny-orm_2.12\jars\skinny-orm_2.12-2.3.2.jar;C:\Users\alpha\.ivy2\cache\org.skinny-framework\skinny-micro-common_2.12\jars\skinny-micro-common_2.12-1.2.1.jar;C:\Users\alpha\.ivy2\cache\org.skinny-framework\skinny-common_2.12\jars\skinny-common_2.12-2.3.2.jar;C:\Users\alpha\.ivy2\cache\org.scalikejdbc\scalikejdbc_2.12\jars\scalikejdbc_2.12-2.5.0.jar;C:\Users\alpha\.ivy2\cache\org.scalikejdbc\scalikejdbc-syntax-support-macro_2.12\jars\scalikejdbc-syntax-support-macro_2.12-2.5.0.jar;C:\Users\alpha\.ivy2\cache\org.scalikejdbc\scalikejdbc-interpolation_2.12\jars\scalikejdbc-interpolation_2.12-2.5.0.jar;C:\Users\alpha\.ivy2\cache\org.scalikejdbc\scalikejdbc-interpolation-macro_2.12\jars\scalikejdbc-interpolation-macro_2.12-2.5.0.jar;C:\Users\alpha\.ivy2\cache\org.scalikejdbc\scalikejdbc-core_2.12\jars\scalikejdbc-core_2.12-2.5.0.jar;C:\Users\alpha\.ivy2\cache\org.scalikejdbc\scalikejdbc-config_2.12\jars\scalikejdbc-config_2.12-2.5.0.jar;C:\Users\alpha\.ivy2\cache\org.scala-lang.modules\scala-parser-combinators_2.12\bundles\scala-parser-combinators_2.12-1.0.4.jar;C:\Users\alpha\.ivy2\cache\org.scala-lang\scala-reflect\jars\scala-reflect-2.12.1.jar;C:\Users\alpha\.ivy2\cache\org.scala-lang\scala-library\jars\scala-library-2.12.1.jar;C:\Users\alpha\.ivy2\cache\org.flywaydb\flyway-core\jars\flyway-core-4.0.3.jar;C:\Users\alpha\Desktop\Coursera\skinny_jdbc\lib\sqljdbc42.jar;C:\Users\alpha\.ivy2\cache\org.slf4j\slf4j-api\jars\slf4j-api-1.7.22.jar;C:\Users\alpha\.ivy2\cache\org.joda\joda-convert\jars\joda-convert-1.8.1.jar;C:\Users\alpha\.ivy2\cache\org.apache.commons\commons-dbcp2\jars\commons-dbcp2-2.1.1.jar;C:\Users\alpha\.ivy2\cache\joda-time\joda-time\jars\joda-time-2.9.6.jar;C:\Users\alpha\.ivy2\cache\commons-logging\commons-logging\jars\commons-logging-1.2.jar;C:\Users\alpha\.ivy2\cache\com.typesafe\config\bundles\config-1.3.1.jar;C:\Users\alpha\.ivy2\cache\com.h2database\h2\jars\h2-1.4.193.jar;C:\Users\alpha\.ivy2\cache\ch.qos.logback\logback-core\jars\logback-core-1.1.8.jar;C:\Users\alpha\.ivy2\cache\ch.qos.logback\logback-classic\jars\logback-classic-1.1.8.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2016.3\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain sk_test
In SK_test object
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/pool/ObjectPool
at scalikejdbc.CommonsConnectionPoolFactory$.apply(CommonsConnectionPoolFactory.scala:16)
at scalikejdbc.CommonsConnectionPoolFactory$.apply(CommonsConnectionPoolFactory.scala:8)
at scalikejdbc.ConnectionPool$.add(ConnectionPool.scala:116)
at scalikejdbc.config.DBs.setup(DBs.scala:16)
at scalikejdbc.config.DBs.setup$(DBs.scala:10)
at skinny.SkinnyDBsWithEnv.setup(SkinnyDBsWithEnv.scala:9)
at scalikejdbc.config.DBs.$anonfun$setupAll$1(DBs.scala:21)
at scalikejdbc.config.DBs.$anonfun$setupAll$1$adapted(DBs.scala:21)
at scala.collection.immutable.List.foreach(List.scala:378)
at scalikejdbc.config.DBs.setupAll(DBs.scala:21)
at scalikejdbc.config.DBs.setupAll$(DBs.scala:19)
at skinny.SkinnyDBsWithEnv.setupAll(SkinnyDBsWithEnv.scala:9)
at skinny.DBSettingsInitializer.initialize(DBSettingsInitializer.scala:25)
at skinny.DBSettingsInitializer.initialize$(DBSettingsInitializer.scala:21)
at skinny.DBSettings$.initialize(DBSettings.scala:8)
at sk_test$.delayedEndpoint$sk_test$1(sk_test.scala:13)
at sk_test$delayedInit$body.apply(sk_test.scala:10)
at scala.Function0.apply$mcV$sp(Function0.scala:34)
at scala.Function0.apply$mcV$sp$(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App.$anonfun$main$1$adapted(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:378)
at scala.App.main(App.scala:76)
at scala.App.main$(App.scala:74)
at sk_test$.main(sk_test.scala:10)
at sk_test.main(sk_test.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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.pool.ObjectPool
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 31 more
I believe you used the application.conf as suggested in the website. This should work fine.
development {
db {
default {
driver="org.h2.Driver"
url="jdbc:h2:file:./db/development;MODE=PostgreSQL;AUTO_SERVER=TRUE"
user="sa"
password="sa"
poolInitialSize=2
poolMaxSize=10
}
}
}
Or you have to include commons-dbcp in your build.sbt to pull in the library as a dependency
I submitted my jar with dependencies to spark using spark-submit. In main method of my jar I want to create HttpAsyncCliens instance and execute some request (apache http async client library):
val httpClient = HttpAsyncClients.custom.setMaxConnTotal(10).setMaxConnPerRoute(10).build
httpClient.start()
httpClient.execute(new HttpGet("https://google.com"), new FutureCallback[HttpResponse] {
/* callbacks */
})
It throws exceptions:
Exception in thread "pool-1-thread-1" java.lang.NoSuchMethodError:
org.apache.http.util.Asserts.check(ZLjava/lang/String;Ljava/lang/Object;)V
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:315)
at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:191)
at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64)
at java.lang.Thread.run(Thread.java:745) Exception in thread "main" java.lang.NoSuchMethodError:
org.apache.http.util.Asserts.check(ZLjava/lang/String;Ljava/lang/Object;)V
at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase.ensureRunning(CloseableHttpAsyncClientBase.java:90)
at org.apache.http.impl.nio.client.InternalHttpAsyncClient.execute(InternalHttpAsyncClient.java:123)
at org.apache.http.impl.nio.client.CloseableHttpAsyncClient.execute(CloseableHttpAsyncClient.java:74)
at org.apache.http.impl.nio.client.CloseableHttpAsyncClient.execute(CloseableHttpAsyncClient.java:107)
at org.apache.http.impl.nio.client.CloseableHttpAsyncClient.execute(CloseableHttpAsyncClient.java:91)
at spark.Application$.main(Application.scala:37)
at spark.Application.main(Application.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:498)
at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:731)
at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:181)
at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:206)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:121)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
It seems like there is no http-core dependency in my jar but I can call this method (org.apache.http.util.Asserts.check(ZLjava/lang/String;Ljava/lang/Object;)V) in code before or after http client creation and request:
org.apache.http.util.Asserts.check(true, "test", "test2") // it produces no exception
val httpClient = HttpAsyncClients.custom.setMaxConnTotal(10).setMaxConnPerRoute(10).build
httpClient.start()
httpClient.execute(new HttpGet("https://google.com"), new FutureCallback[HttpResponse] {
/* callbacks */
}) // it produces exception
Why I got NoSuchMethodError if I can call this method from same classpath in code?
Apache httpasyncclient v4.1
The solution here is to sync up with the version of httpcomponents.httpcore that is in the immediate classpath of spark. For version 1.6 the version is 4.0.1.
You will have to unzip the spark jar to view the META-INF, etc. After some detective work things will be alright!
I am trying to use Caliper with Scala(2.10) in Eclipse Juno(4.2). For the start I've set up a benchmark that simply iterates a foreachloop over an array.
import com.google.caliper.Param
import com.google.caliper.SimpleBenchmark
class Benchmark extends SimpleBenchmark {
#Param(Array("10", "100", "1000", "10000"))
val length: Int = 0
var array: Array[Int] = _
override def setUp() {
array = new Array(length)
}
def timeForeach(reps: Int) = {
var result = 0
array.foreach {
result += _
}
result
}
When I start the benchmark with:
object myRunner {
def main(args: Array[String]) {
Runner.main(classOf[Benchmark], args)
}
}
I get these exceptions that I dont understand
0% Scenario{vm=java, trial=0, benchmark=Foreach, length=10} Failed to execute java -cp C:\Users\bob\workspace\myBenchmark\bin;C:\Users\bob\workspace\caliper\caliper\target>\classes;C:\Users\bob\workspace\caliper\caliper\target\test-classes;C:\Users\bob\.m2\repository\com\google\code\findbugs\jsr305\1.3.9\jsr305-1.3.9.jar;C:\Users\bob\.m2\repository\com\google\code\gson\gson\1.7.1\gson-1.7.1.jar;C:\Users\bob\.m2\repository\com\google\guava\guava\11.0.1\guava-11.0.1.jar;C:\Users\bob\.m2\repository\com\google\code\java-allocation-instrumenter\java-allocation-instrumenter\2.0\java-allocation-instrumenter-2.0.jar;C:\Users\bob\.m2\repository\asm\asm\3.3.1\asm-3.3.1.jar;C:\Users\bob\.m2\repository\asm\asm-analysis\3.3.1\asm-analysis-3.3.1.jar;C:\Users\bob\.m2\repository\asm\asm-commons\3.3.1\asm-commons-3.3.1.jar;C:\Users\bob\.m2\repository\asm\asm-tree\3.3.1\asm-tree-3.3.1.jar;C:\Users\bob\.m2\repository\asm\asm-util\3.3.1\asm-util-3.3.1.jar;C:\Users\bob\.m2\repository\asm\asm-xml\3.3.1\asm-xml-3.3.1.jar;C:\Users\bob\.m2\repository\junit\junit\3.8.2\junit-3.8.2.jar com.google.caliper.InProcessRunner --warmupMillis 3000 --runMillis 1000 --measurementType TIME --marker //ZxJ/ -Dbenchmark=Foreach -Dlength=10 org.example.Benchmark
Exception in thread "main" java.lang.NoClassDefFoundError: scala/Function1
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.google.caliper.ScenarioSelection.getClassByName(ScenarioSelection.java:154)
at com.google.caliper.ScenarioSelection.prepareSuite(ScenarioSelection.java:123)
at com.google.caliper.ScenarioSelection.select(ScenarioSelection.java:83)
at com.google.caliper.InProcessRunner.run(InProcessRunner.java:38)
at com.google.caliper.InProcessRunner.main(InProcessRunner.java:103)
Caused by: java.lang.ClassNotFoundException: scala.Function1
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
An exception was thrown from the benchmark code.
com.google.caliper.ConfigurationException: Failed to execute java -cp C:\Users\bob\workspace\myBenchmark\bin;C:\Users\bob\workspace\caliper\caliper\target\classes;C:\Users\bob\workspace\caliper\caliper\target\test-classes;C:\Users\bob\.m2\repository\com\google\code\findbugs\jsr305\1.3.9\jsr305-1.3.9.jar;C:\Users\bob\.m2\repository\com\google\code\gson\gson\1.7.1\gson-1.7.1.jar;C:\Users\bob\.m2\repository\com\google\guava\guava\11.0.1\guava-11.0.1.jar;C:\Users\bob\.m2\repository\com\google\code\java-allocation-instrumenter\java-allocation-instrumenter\2.0\java-allocation-instrumenter-2.0.jar;C:\Users\bob\.m2\repository\asm\asm\3.3.1\asm-3.3.1.jar;C:\Users\bob\.m2\repository\asm\asm-analysis\3.3.1\asm-analysis-3.3.1.jar;C:\Users\bob\.m2\repository\asm\asm-commons\3.3.1\asm-commons-3.3.1.jar;C:\Users\bob\.m2\repository\asm\asm-tree\3.3.1\asm-tree-3.3.1.jar;C:\Users\bob\.m2\repository\asm\asm-util\3.3.1\asm-util-3.3.1.jar;C:\Users\bob\.m2\repository\asm\asm-xml\3.3.1\asm-xml-3.3.1.jar;C:\Users\bob\.m2\repository\junit\junit\3.8.2\junit-3.8.2.jar com.google.caliper.InProcessRunner --warmupMillis 3000 --runMillis 1000 --measurementType TIME --marker //ZxJ/ -Dbenchmark=Foreach -Dlength=10 org.example.Benchmark
at com.google.caliper.Runner.measure(Runner.java:309)
at com.google.caliper.Runner.runScenario(Runner.java:229)
at com.google.caliper.Runner.runOutOfProcess(Runner.java:378)
at com.google.caliper.Runner.run(Runner.java:97)
at com.google.caliper.Runner.main(Runner.java:423)
at com.google.caliper.Runner.main(Runner.java:436)
at org.example.myRunner$.main(myRunner.scala:7)
at org.example.myRunner.main(myRunner.scala)
I think I have some issues with the classpath but i am not sure.
I hope someone can help me :)
thanks in advance
Davram Bashere
It looks very much as though Caliper is running a new JVM and doesn't know that it needs to include the Scala libraries on the classpath.
This question describes how to run a Scala app with the java command on the command line. It should be a good starting point to solving this problem.
Even if you are editing scala sources in Eclipse you may still use sbt to run your code. Sbt is a great tool for managing your projects classpath in addition to providing a plugin system for providing the kinds of features like running Caliper benchmarks. I recently worked on a project where I needed just that and factored it out into an published sbt plugin. This may be of some help for you as well.
Thanks for your help. The problem was as expected the stupid classpath. I have downloaded the caliper project from googlecode and added the scala dependency. Now I've build my own jar-with-dependencies and it works quite fine.
Thanks for the answeres anyway :-)