I have two 3rd party libraries I need to use in my application. Both use Akka, but they use different versions (2.1 and 2.3, I think). Since I need to use these versions together in the same JVM (I don't need 2.1 and 2.3 to talk to each other, just share a VM), I started looking at loading these libraries using separate classloaders. I ran into this exception, which (just from looking at the stack trace) makes me think that Akka is trying to load classes in an unusual way. ReflectiveDynamicAccess is the name that makes me wonder this.
Whatever the reason, Akka can't find classes that are in the same jar with the classes that had to be loaded in order to even get this far. Does anyone have suggestions about better ways to deal with this situation? Is anyone using OSGi for this kind of thing? Please let me know if the question isn't clear or if I'm overlooking something simple.
Exception in thread "main" java.lang.ClassNotFoundException: akka.remote.RemoteActorRefProvider
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)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at akka.actor.ReflectiveDynamicAccess$$anonfun$getClassFor$1.apply(DynamicAccess.scala:67)
at akka.actor.ReflectiveDynamicAccess$$anonfun$getClassFor$1.apply(DynamicAccess.scala:66)
at scala.util.Try$.apply(Try.scala:161)
at akka.actor.ReflectiveDynamicAccess.getClassFor(DynamicAccess.scala:66)
at akka.actor.ReflectiveDynamicAccess.createInstanceFor(DynamicAccess.scala:84)
at akka.actor.ActorSystemImpl.liftedTree1$1(ActorSystem.scala:584)
at akka.actor.ActorSystemImpl.<init>(ActorSystem.scala:577)
at akka.actor.ActorSystem$.apply(ActorSystem.scala:141)
at akka.actor.ActorSystem$.apply(ActorSystem.scala:118)
at org.apache.spark.util.AkkaUtils$.createActorSystem(AkkaUtils.scala:96)