Using Akka in Karaf: No configuration setting found for key 'akka.version'

765 views
Skip to first unread message

Daniele Ascione

unread,
Sep 20, 2016, 9:44:58 AM9/20/16
to Akka User List
I looked in the Akka User List for a long time, but I coudn't find anything which helped me in this situation. Sorry if this is a duplicated answer.
I'm trying to create an akka "Hello World" bundle (inspired by the this example), and I'm trying to start it in Karaf.
I wrote this activator in java:
public class AkkaActivator extends ActorSystemActivator {

ActorSystem actorSystem; 
ActorRef actorRef;
@Override
public void configure(BundleContext context, ActorSystem system) {
Config regularConfig = ConfigFactory.load();
String sysName = system.name();
ActorSystem.apply(sysName, regularConfig);
actorRef = system.actorOf(Props.create(HelloWorld.class), "helloWorld");
system.actorOf(Props.create(Terminator.class, actorRef), "terminator");
}

}

 , which I deployed in a jar using the maven-bundle-plugin.
I wrote also a reference.conf file which is inserted by maven plugin in the root of the created jar. The file is the following one:
  
akka {
  loglevel = INFO
}


All the code is avaible in this repo.
When I try to start the bundle from karaf, I obtain the following exception:

2016-09-20 15:20:15,560 | ERROR | nsole user karaf | ShellUtil                        | 44 - org.apache.karaf.shell.core - 4.0.5 | Exception caught while executing command
org.apache.karaf.shell.support.MultiException: Error executing command on bundles:
Error starting bundle 327: Activator start error in bundle com.example.akka-poc-bundle [327].
at org.apache.karaf.shell.support.MultiException.throwIf(MultiException.java:61)
at org.apache.karaf.bundle.command.BundlesCommand.doExecute(BundlesCommand.java:69)[24:org.apache.karaf.bundle.core:4.0.5]
at org.apache.karaf.bundle.command.BundlesCommand.execute(BundlesCommand.java:54)[24:org.apache.karaf.bundle.core:4.0.5]
at org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:83)[44:org.apache.karaf.shell.core:4.0.5]
at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:67)[44:org.apache.karaf.shell.core:4.0.5]
at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:87)[44:org.apache.karaf.shell.core:4.0.5]
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:480)[44:org.apache.karaf.shell.core:4.0.5]
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:406)[44:org.apache.karaf.shell.core:4.0.5]
at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[44:org.apache.karaf.shell.core:4.0.5]
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:182)[44:org.apache.karaf.shell.core:4.0.5]
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:119)[44:org.apache.karaf.shell.core:4.0.5]
at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:94)[44:org.apache.karaf.shell.core:4.0.5]
at org.apache.karaf.shell.impl.console.ConsoleSessionImpl.run(ConsoleSessionImpl.java:270)[44:org.apache.karaf.shell.core:4.0.5]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_91]
Caused by: java.lang.Exception: Error starting bundle 327: Activator start error in bundle com.example.akka-poc-bundle [327].
at org.apache.karaf.bundle.command.BundlesCommand.doExecute(BundlesCommand.java:66)[24:org.apache.karaf.bundle.core:4.0.5]
... 12 more
Caused by: org.osgi.framework.BundleException: Activator start error in bundle com.example.akka-poc-bundle [327].
at org.apache.felix.framework.Felix.activateBundle(Felix.java:2276)[org.apache.felix.framework-5.4.0.jar:]
at org.apache.felix.framework.Felix.startBundle(Felix.java:2144)[org.apache.felix.framework-5.4.0.jar:]
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)[org.apache.felix.framework-5.4.0.jar:]
at org.apache.karaf.bundle.command.Start.executeOnBundle(Start.java:38)[24:org.apache.karaf.bundle.core:4.0.5]
at org.apache.karaf.bundle.command.BundlesCommand.doExecute(BundlesCommand.java:64)[24:org.apache.karaf.bundle.core:4.0.5]
... 12 more
Caused by: com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'akka.version'
at com.typesafe.config.impl.SimpleConfig.findKeyOrNull(SimpleConfig.java:152)[327:com.example.akka-poc-bundle:0.0.1]
at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:170)[327:com.example.akka-poc-bundle:0.0.1]
at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:176)[327:com.example.akka-poc-bundle:0.0.1]
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:184)[327:com.example.akka-poc-bundle:0.0.1]
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:189)[327:com.example.akka-poc-bundle:0.0.1]
at com.typesafe.config.impl.SimpleConfig.getString(SimpleConfig.java:246)[327:com.example.akka-poc-bundle:0.0.1]
at akka.actor.ActorSystem$Settings.<init>(ActorSystem.scala:168)[327:com.example.akka-poc-bundle:0.0.1]
at akka.actor.ActorSystemImpl.<init>(ActorSystem.scala:522)[327:com.example.akka-poc-bundle:0.0.1]
at akka.actor.ActorSystem$.apply(ActorSystem.scala:142)[327:com.example.akka-poc-bundle:0.0.1]
at akka.actor.ActorSystem$.apply(ActorSystem.scala:126)[327:com.example.akka-poc-bundle:0.0.1]
at akka.osgi.OsgiActorSystemFactory.createActorSystem(OsgiActorSystemFactory.scala:32)[327:com.example.akka-poc-bundle:0.0.1]
at akka.osgi.ActorSystemActivator.start(ActorSystemActivator.scala:42)[327:com.example.akka-poc-bundle:0.0.1]
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:697)[org.apache.felix.framework-5.4.0.jar:]
at org.apache.felix.framework.Felix.activateBundle(Felix.java:2226)[org.apache.felix.framework-5.4.0.jar:]
... 16 more
I noticed that if I modify the reference.conf file adding the line:
version = 2.4.10
Instead of getting:
No configuration setting found for key 'akka.version'
I obtain:
No configuration setting found for key 'akka.actor'

I could I solve this problem?


Johan Andrén

unread,
Sep 20, 2016, 9:57:33 AM9/20/16
to Akka User List

Daniele Ascione

unread,
Sep 20, 2016, 10:51:56 AM9/20/16
to Akka User List
Hi Johan, thank you so much for your answer!

I read the section of the doc that you said, but I could not resolve my issue.
I think that the problem doesn't come from configuration files (but i may be wrong).
I'll try to explain what I mean better: in this example [ http://www.lightbend.com/activator/template/akka-sample-main-java ] with source code [ https://github.com/akka/akka/tree/master/akka-samples/akka-sample-main-java ],
you can run akka (from main) even if you don't write any application.conf , just accepting default configurations. But if I try to do the same thing starting the bundle (that is, putting no conf files in the jar) with the activator I wrote, I have this exception:

Caused by: com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'akka'
  at com.typesafe.config.impl.SimpleConfig.findKeyOrNull(SimpleConfig.java:152)[327:com.example.akka-poc-bundle:0.0.1]
   at com.typesafe.config.impl.SimpleConfig.findKey(SimpleConfig.java:145)[327:com.example.akka-poc-bundle:0.0.1]
 at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:172)[327:com.example.akka-poc-bundle:0.0.1]
      at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:184)[327:com.example.akka-poc-bundle:0.0.1]
    at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:189)[327:com.example.akka-poc-bundle:0.0.1]
    at com.typesafe.config.impl.SimpleConfig.getString(SimpleConfig.java:246)[327:com.example.akka-poc-bundle:0.0.1]
       at akka.actor.ActorSystem$Settings.<init>(ActorSystem.scala:168)[327:com.example.akka-poc-bundle:0.0.1]
at akka.actor.ActorSystemImpl.<init>(ActorSystem.scala:522)[327:com.example.akka-poc-bundle:0.0.1]
     at akka.actor.ActorSystem$.apply(ActorSystem.scala:142)[327:com.example.akka-poc-bundle:0.0.1]
 at akka.actor.ActorSystem$.apply(ActorSystem.scala:126)[327:com.example.akka-poc-bundle:0.0.1]
 at akka.osgi.OsgiActorSystemFactory.createActorSystem(OsgiActorSystemFactory.scala:32)[327:com.example.akka-poc-bundle:0.0.1]
  at akka.osgi.ActorSystemActivator.start(ActorSystemActivator.scala:42)[327:com.example.akka-poc-bundle:0.0.1]
  at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:697)[org.apache.felix.framework-5.4.0.jar:]
   at org.apache.felix.framework.Felix.activateBundle(Felix.java:2226)[org.apache.felix.framework-5.4.0.jar:]
     ... 16 more

Johan Andrén

unread,
Sep 20, 2016, 10:59:07 AM9/20/16
to Akka User List
The reason you get that error is what the big red warning in the docs:

"Akka's configuration approach relies heavily on the notion of every module/jar having its own reference.conf file, all of these will be discovered by the configuration and loaded. Unfortunately this also means that if you put/merge multiple jars into the same jar, you need to merge all the reference.confs as well. Otherwise all defaults will be lost and Akka will not function."

When merging the jar files of many Akka modules reference.conf must be each of the reference.conf in the modules merged into a single file and included in the superjar (how this is done with the maven plugin you mention I cannot say). 

Your application config should be put in application.conf.

--
Johan
Akka Team
Reply all
Reply to author
Forward
0 new messages