Chris Murphy
Chris Murphy

Reputation: 6509

lein uberjar - No configuration setting found for key 'akka.version'

I can create an uberjar that is composed of lots of class files, originally Scala, Java, Clojure. The problem I have is that when I run java -jar my-server.jar it crashes with:

No configuration setting found for key 'akka.version'

This is to be expected and has a maven solution. The yellow writing on the accepted answer here is basically Akka saying "you shouldn't build uberjars with Akka jars in them, as then Akka won't be able to find its .conf files."

I am trying this as a lein solution:

:pom-plugins [[org.apache.maven.plugins/maven-shade-plugin 2.2]]

I have a local maven repository (by this I mean not the ~/.m2 one, but a local one that is used to introduce non-Clojars jars into the lein build). Maybe I need to lein deploy localrepo1 for the akka jars again to pick up this new setting - Nope - that didn't help.

Here's some of the stack trace to make it clear where the problem comes from:

Exception in thread "main" com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'akka.version'
    at com.typesafe.config.impl.SimpleConfig.findKey(SimpleConfig.java:124)
    at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:145)
    at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:151)
    at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:159)
    at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:164)
    at com.typesafe.config.impl.SimpleConfig.getString(SimpleConfig.java:206)
    at akka.actor.ActorSystem$Settings.<init>(ActorSystem.scala:169)
    at akka.actor.ActorSystemImpl.<init>(ActorSystem.scala:505)
    at akka.actor.ActorSystem$.apply(ActorSystem.scala:142)
    at akka.actor.ActorSystem$.apply(ActorSystem.scala:109)
    at com.seasoft.comms.MyPLCActorHolder.createRefToLocalActor(MyPLCActorHolder.scala:39)

Edit I've now looked inside the jar files. There are two akka jar files that both have a reference.conf in them. These files are not correctly merged because (unsurprisingly) lein uberjar doesn't understand the nesting of the property key/values within them.

Specifically the reference.conf in akka-actor_2.11-2.3.9.jar has akka.version = "2.3.9", but this entry has not made it to the merged reference.conf. I altered the uberjar and that fixed the problem, of course giving me the next merge problem. So the fix here is to manually do the merge myself.

And the better fix would be to write a little merging program (with two functions: a predicate and merge) and get it into akka so that people who write build tools can just use it...

Upvotes: 1

Views: 559

Answers (2)

Laurence Chen
Laurence Chen

Reputation: 1848

I changed spark version to avoid this kind of problem. Spark 2.1.0 does not depend on Akka, and does not have the Akka reference.conf problem.

Upvotes: 0

Chris Murphy
Chris Murphy

Reputation: 6509

Manually merging reference.conf from the two jars and then manually altering the uberjar (overwriting the existing reference.conf) did the trick. The merged file is here.

I believe this problem will occur anytime there are property files that come from different jars that have the same name. For instance log4j.properties also needed to be overwritten.

Upvotes: 0

Related Questions