No configuration setting found for key 'akka.version'

匿名 (未验证) 提交于 2018-03-17 14:53:49

问题:

I am learning akka-remoting and this is how my project looks

The project structure looks like

project/pom.xml
project/mymodule/pom.xml
project/mymodule/src/main/resources/application.conf
project/mymodule/src/main/scala/com.harit.akkaio.remote.RemoteApp.scala
project/mymodule/src/main/scala/com.harit.akkaio.remote.ProcessingActor.scala

When I run my project on command-line, I see

$ java -jar akkaio-remote/target/akka-remote-jar-with-dependencies.jar com.harit.akkaio.remote.RemoteApp
Hello:com.harit.akkaio.remote.RemoteApp
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.(ActorSystem.scala:169)
    at akka.actor.ActorSystemImpl.(ActorSystem.scala:505)
    at akka.actor.ActorSystem$.apply(ActorSystem.scala:142)
    at akka.actor.ActorSystem$.apply(ActorSystem.scala:119)
    at com.harit.akkaio.remote.RemoteApp$.startProcessingActorSystem(RemoteApp.scala:16)
    at com.harit.akkaio.remote.RemoteApp$.main(RemoteApp.scala:12)
    at com.harit.akkaio.remote.RemoteApp.main(RemoteApp.scala)

RemoteApp.scala

package com.harit.akkaio.remote

import akka.actor.{ActorRef, ActorSystem, Props}
import com.typesafe.config.ConfigFactory

import scala.concurrent.duration._

object RemoteApp {
  def main(args: Array[String]): Unit = {
    println("Hello:" + args.head)
      startProcessingActorSystem()
  }

  def startProcessingActorSystem() = {
    val system = ActorSystem("ProcessingSystem", ConfigFactory.load())
    println("ProcessingActorSystem Started")
  }
}

ProcessingActor.scala

package com.harit.akkaio.remote

import akka.actor.{Actor, ActorLogging}

case object Process

case object Crash

class ProcessingActor extends Actor with ActorLogging {
  def receive = {
    case Process => log.info("processing big things")
    case Crash => log.info("crashing the system")
      context.stop(self)
  }
}

application.conf

akka {
  remote.netty.tcp.port = 2552
}

mymodule.pom.xml



    
        akkaio
        com.harit
        1.0-SNAPSHOT
    
    4.0.0

    akkaio-remote

    
        2.3.11
    

    
        
            com.typesafe.akka
            akka-remote_2.11
            ${akka-remote_2.11.version}
        
    

    
        
            
                maven-assembly-plugin
                
                    akka-remote
                    
                        
                            com.harit.akkaio.remote.RemoteApp
                        
                    
                    
                        jar-with-dependencies
                    
                
                
                    
                        make-assembly 
                        package 
                        
                            single
                        
                    
                
            
        
    

pom.xml



    4.0.0

    com.harit
    akkaio
    1.0-SNAPSHOT
    
        akkaio-remote
    

    pom
    2015
    
        2.11.6
        4.12
        2.2.5
        2.3.11
        2.3.11
        2.3.11
        1.10.19
        2.11.6
        1.0
    

    
        
            scala-tools.org
            Scala-Tools Maven2 Repository
            http://scala-tools.org/repo-releases
        
    

    
        
            scala-tools.org
            Scala-Tools Maven2 Repository
            http://scala-tools.org/repo-releases
        
    

    
        
            org.scala-lang
            scala-library
            ${scala.version}
        
        
            com.typesafe.akka
            akka-actor_2.11
            ${akka-actor_2.11.version}
        
        
            com.typesafe.akka
            akka-slf4j_2.11
            ${akka-slf4j_2.11.version}
        
        
            org.scalatest
            scalatest-maven-plugin
            ${scalatest-maven-plugin.version}
            compile
        
        
            com.typesafe.akka
            akka-testkit_2.11
            ${akka-testkit_2.11.version}
            test
        
        
            org.scalatest
            scalatest_2.11
            ${scalatest_2.11.version}
            test
        
    

    
        clean install
        
            
                org.scala-tools
                maven-scala-plugin
                
                    
                        
                            compile
                            testCompile
                        
                    
                
                
                    ${maven-scala-plugin.scalaCompatVersion}
                    ${scala.version}
                    ${scala.version}
                    
                        -target:jvm-1.8
                    
                
            
            
                org.apache.maven.plugins
                maven-surefire-plugin
                2.7
                
                    true
                
            
            
                org.scalatest
                scalatest-maven-plugin
                1.0
                
                    ${project.build.directory}/surefire-reports
                    .
                    WDF TestSuite.txt
                
                
                    
                        test
                        
                            test
                        
                    
                
            
        
    
    
        
            
                org.scala-tools
                maven-scala-plugin
                
                    ${scala.version}
                
            
        
    

What am I missing out? Thanks

回答1:

It seems that your problem is bundling into a jar-with-dependencies, which causes problems with Akka, as described in the documentation:

Warning

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.

As suggested on the same page, you can use maven-shade-plugin to merge all the reference configurations:

If you are using Maven to package your application, you can also make use of the Apache Maven Shade Plugin support for Resource Transformers to merge all the reference.confs on the build classpath into one.

See also: Akka: missing akka.version



回答2:

Had a simular issue:

com.typesafe.config.ConfigException$Missing: 
No configuration setting found for key 'akka.persistence.journal-plugin-fallback'

Solved it with adding an appending transformer:


  maven-shade-plugin
  2.4.1
  
    
      package
      
        shade
      
      
        
          
            reference.conf
          
        
      
    
  



回答3:

Adding AppendingTransformer alone didn't resolve the issue for me. If you are trying to deploy your spark application on EMR and are still facing this issue then please take a look at my solution here. Hope it helps!