Classpath Bug -
Nikolay Botev
bono8106 at gmail.com
Sat Jul 11 20:19:26 UTC 2015
Nikolays-MacBook-Air:bin nbotev$ uname -a
Darwin Nikolays-MacBook-Air.local 14.4.0 Darwin Kernel Version 14.4.0: Thu May 28 11:35:04 PDT 2015; root:xnu-2782.30.5~1/RELEASE_X86_64 x86_64
Nikolays-MacBook-Air:bin nbotev$ java -version
java version "1.9.0-ea"
Java(TM) SE Runtime Environment (build 1.9.0-ea-b72)
Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b72, mixed mode)
JShell verison: kulla-0.610-20150709005843
——
Summary: Adding a library to the class path after loading a class that depends on that library does not reload the class.
Reproduction Steps:
- Download akka from http://downloads.typesafe.com/akka/akka_2.11-2.3.12.zip?_ga=1.210377941.1593193379.1436640268
- Run in jshell:
Nikolays-MacBook-Air:bin nbotev$ jshell
| Welcome to JShell -- Version 0.610
| Type /help for help
-> /classpath ~/Downloads/akka-2.3.12/lib/scala-library-2.11.5.jar
| Path ~/Downloads/akka-2.3.12/lib/scala-library-2.11.5.jar added to classpath
-> /classpath ~/Downloads/akka-2.3.12/lib/akka/akka-actor_2.11-2.3.12.jar
| Path ~/Downloads/akka-2.3.12/lib/akka/akka-actor_2.11-2.3.12.jar added to classpath
-> akka.actor.ActorSystem system = akka.actor.ActorSystem.create("MySystem")
| java.lang.NoClassDefFoundError thrown: com/typesafe/config/ConfigFactory
| at ActorSystem$$anonfun$5.apply (ActorSystem.scala:141)
| at ActorSystem$$anonfun$5.apply (ActorSystem.scala:141)
| at Option.getOrElse (Option.scala:121)
| at ActorSystem$.apply (ActorSystem.scala:141)
| at ActorSystem$.apply (ActorSystem.scala:109)
| at ActorSystem$.create (ActorSystem.scala:57)
| at ActorSystem.create (ActorSystem.scala)
| at (#9:1)
-> /classpath ~/Downloads/akka-2.3.12/lib/akka/config-1.2.1.jar
| Path ~/Downloads/akka-2.3.12/lib/akka/config-1.2.1.jar added to classpath
-> akka.actor.ActorSystem system = akka.actor.ActorSystem.create("MySystem")
| java.lang.NoClassDefFoundError thrown: com/typesafe/config/ConfigFactory
| at ActorSystem$$anonfun$5.apply (ActorSystem.scala:141)
| at ActorSystem$$anonfun$5.apply (ActorSystem.scala:141)
| at Option.getOrElse (Option.scala:121)
| at ActorSystem$.apply (ActorSystem.scala:141)
| at ActorSystem$.apply (ActorSystem.scala:109)
| at ActorSystem$.create (ActorSystem.scala:57)
| at ActorSystem.create (ActorSystem.scala)
| at (#9:1)
-> /classpath ~/Downloads/akka-2.3.12/lib/akka/akka-actor_2.11-2.3.12.jar
| Path ~/Downloads/akka-2.3.12/lib/akka/akka-actor_2.11-2.3.12.jar added to classpath
-> akka.actor.ActorSystem system = akka.actor.ActorSystem.create("MySystem")
| java.lang.NoClassDefFoundError thrown: com/typesafe/config/ConfigFactory
| at ActorSystem$$anonfun$5.apply (ActorSystem.scala:141)
| at ActorSystem$$anonfun$5.apply (ActorSystem.scala:141)
| at Option.getOrElse (Option.scala:121)
| at ActorSystem$.apply (ActorSystem.scala:141)
| at ActorSystem$.apply (ActorSystem.scala:109)
| at ActorSystem$.create (ActorSystem.scala:57)
| at ActorSystem.create (ActorSystem.scala)
| at (#9:1)
Workaround:
Load the JAR *before* referencing the class that depends on classes in the JAR, as below:
Nikolays-MacBook-Air:bin nbotev$ jshell
| Welcome to JShell -- Version 0.610
| Type /help for help
-> /classpath ~/Downloads/akka-2.3.12/lib/scala-library-2.11.5.jar
| Path ~/Downloads/akka-2.3.12/lib/scala-library-2.11.5.jar added to classpath
-> /classpath ~/Downloads/akka-2.3.12/lib/akka/akka-actor_2.11-2.3.12.jar
| Path ~/Downloads/akka-2.3.12/lib/akka/akka-actor_2.11-2.3.12.jar added to classpath
-> /classpath ~/Downloads/akka-2.3.12/lib/akka/config-1.2.1.jar
| Path ~/Downloads/akka-2.3.12/lib/akka/config-1.2.1.jar added to classpath
-> akka.actor.ActorSystem system = akka.actor.ActorSystem.create("MySystem")
| com.typesafe.config.ConfigException$Missing thrown: No configuration setting found for key 'akka'
| at SimpleConfig.findKey (SimpleConfig.java:124)
| at SimpleConfig.find (SimpleConfig.java:147)
| at SimpleConfig.find (SimpleConfig.java:159)
| at SimpleConfig.find (SimpleConfig.java:164)
| at SimpleConfig.getString (SimpleConfig.java:206)
| at ActorSystem$Settings.<init> (ActorSystem.scala:169)
| at ActorSystemImpl.<init> (ActorSystem.scala:505)
| at ActorSystem$.apply (ActorSystem.scala:142)
| at ActorSystem$.apply (ActorSystem.scala:109)
| at ActorSystem$.create (ActorSystem.scala:57)
| at ActorSystem.create (ActorSystem.scala)
| at (#9:1)
More information about the kulla-dev
mailing list