no configuration setting found for key akka
Asked Answered
L

3

31

I am using scala, spray and akka for one of my projects. In Intellij, it is working fine. When I build the project and tried to run it in command line, I get the following error.


Caused by: com.typesafe.config.ConfigException$Missing: No configuration setting
 found for key 'akka'
        at com.typesafe.config.impl.SimpleConfig.findKey(SimpleConfig.java:124)
        at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:147)
        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.(ActorSystem.scala:168)
        at akka.actor.ActorSystemImpl.(ActorSystem.scala:504)
        at akka.actor.ActorSystem$.apply(ActorSystem.scala:141)
        at akka.actor.ActorSystem$.apply(ActorSystem.scala:108)
        at akka.actor.ActorSystem$.apply(ActorSystem.scala:99)

Please help me in solving the issue

Lawana answered 6/2, 2015 at 11:40 Comment(4)
You need to provide configuration for akka in your conf file... as simple as that.Becka
That I understood... I am using default config. In ide its working fine..Lawana
Then it may be related to the way you are running it on the command line. How do you run it?Matz
Its because of when we build the projects as a single jar the reference.conf files will be overridden. We have to copy all jars reference.conf to a single reference.conf. it will work fine...:-)Lawana
D
70

The problem is when using sbt:assembly the default merge strategy excludes all the reference.conf files as per

If multiple files share the same relative path (e.g. a resource named application.conf in multiple dependency JARs), the default strategy is to verify that all candidates have the same contents and error out otherwise.

The solution is to add a MergeStrategy as follows

assemblyMergeStrategy in assembly := {
  case PathList("reference.conf") => MergeStrategy.concat
}
Dandridge answered 8/6, 2015 at 15:29 Comment(3)
I get the error in sbt console after doing jetty:start and then exit.Callahan
Where this should be inserted? I tried in build.sbt but it doesn't compile. ( error: not found: value assemblyMergeStrategy, same for assembly, PathList and MergeStrategy)Pry
OK I've found out that I need to add a sbt-assembly plugin, but after that I still get the OP's error. However I don't need a single jar so the source of my problem is differentPry
S
4

Akka will read the configuration file from the following location by default:

  1. application.conf under root of classpath (including in jar)
  2. manually passed in configuration from ActorSystem("name", config).
  3. reference.conf under root of classpath (including in jar)

Please double check your classpath and see if you have a bad classpath reference which indicate a bad root of classpath for akka jars, spray jars, etc.

Spector answered 9/2, 2015 at 17:2 Comment(0)
A
3

maven-shade-plugin configuration for maven users:

<configuration>
    <transformers>
        <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
            <resource>reference.conf</resource>
        </transformer>
    </transformers>
</configuration>

Appositive answered 14/5, 2020 at 7:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.