2015-06-23 4 views
19

मैं अक्का-दूरस्थ सीख रहा हूँ के लिए मिला सेटिंग और यह कैसे अपने प्रोजेक्ट लग रहा हैकोई विन्यास कुंजी 'akka.version'

परियोजना संरचना लग रहा है

तरह
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 

जब मैं command-line पर अपने प्रोजेक्ट को चलाने मैं देख रहा हूँ

$ 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.<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: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

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <parent> 
     <artifactId>akkaio</artifactId> 
     <groupId>com.harit</groupId> 
     <version>1.0-SNAPSHOT</version> 
    </parent> 
    <modelVersion>4.0.0</modelVersion> 

    <artifactId>akkaio-remote</artifactId> 

    <properties> 
     <akka-remote_2.11.version>2.3.11</akka-remote_2.11.version> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>com.typesafe.akka</groupId> 
      <artifactId>akka-remote_2.11</artifactId> 
      <version>${akka-remote_2.11.version}</version> 
     </dependency> 
    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <artifactId>maven-assembly-plugin</artifactId> 
       <configuration> 
        <finalName>akka-remote</finalName> 
        <archive> 
         <manifest> 
          <mainClass>com.harit.akkaio.remote.RemoteApp</mainClass> 
         </manifest> 
        </archive> 
        <descriptorRefs> 
         <descriptorRef>jar-with-dependencies</descriptorRef> 
        </descriptorRefs> 
       </configuration> 
       <executions> 
        <execution> 
         <id>make-assembly</id> <!-- this is used for inheritance merges --> 
         <phase>package</phase> <!-- bind to the packaging phase --> 
         <goals> 
          <goal>single</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

pom.xml

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>com.harit</groupId> 
    <artifactId>akkaio</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <modules> 
     <module>akkaio-remote</module> 
    </modules> 

    <packaging>pom</packaging> 
    <inceptionYear>2015</inceptionYear> 
    <properties> 
     <scala.version>2.11.6</scala.version> 
     <junit.version>4.12</junit.version> 
     <scalatest_2.11.version>2.2.5</scalatest_2.11.version> 
     <akka-actor_2.11.version>2.3.11</akka-actor_2.11.version> 
     <akka-slf4j_2.11.version>2.3.11</akka-slf4j_2.11.version> 
     <akka-testkit_2.11.version>2.3.11</akka-testkit_2.11.version> 
     <mockito-all.version>1.10.19</mockito-all.version> 
     <maven-scala-plugin.scalaCompatVersion>2.11.6</maven-scala-plugin.scalaCompatVersion> 
     <scalatest-maven-plugin.version>1.0</scalatest-maven-plugin.version> 
    </properties> 

    <repositories> 
     <repository> 
      <id>scala-tools.org</id> 
      <name>Scala-Tools Maven2 Repository</name> 
      <url>http://scala-tools.org/repo-releases</url> 
     </repository> 
    </repositories> 

    <pluginRepositories> 
     <pluginRepository> 
      <id>scala-tools.org</id> 
      <name>Scala-Tools Maven2 Repository</name> 
      <url>http://scala-tools.org/repo-releases</url> 
     </pluginRepository> 
    </pluginRepositories> 

    <dependencies> 
     <dependency> 
      <groupId>org.scala-lang</groupId> 
      <artifactId>scala-library</artifactId> 
      <version>${scala.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>com.typesafe.akka</groupId> 
      <artifactId>akka-actor_2.11</artifactId> 
      <version>${akka-actor_2.11.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>com.typesafe.akka</groupId> 
      <artifactId>akka-slf4j_2.11</artifactId> 
      <version>${akka-slf4j_2.11.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.scalatest</groupId> 
      <artifactId>scalatest-maven-plugin</artifactId> 
      <version>${scalatest-maven-plugin.version}</version> 
      <scope>compile</scope> 
     </dependency> 
     <dependency> 
      <groupId>com.typesafe.akka</groupId> 
      <artifactId>akka-testkit_2.11</artifactId> 
      <version>${akka-testkit_2.11.version}</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.scalatest</groupId> 
      <artifactId>scalatest_2.11</artifactId> 
      <version>${scalatest_2.11.version}</version> 
      <scope>test</scope> 
     </dependency> 
    </dependencies> 

    <build> 
     <defaultGoal>clean install</defaultGoal> 
     <plugins> 
      <plugin> 
       <groupId>org.scala-tools</groupId> 
       <artifactId>maven-scala-plugin</artifactId> 
       <executions> 
        <execution> 
         <goals> 
          <goal>compile</goal> 
          <goal>testCompile</goal> 
         </goals> 
        </execution> 
       </executions> 
       <configuration> 
        <scalaCompatVersion>${maven-scala-plugin.scalaCompatVersion}</scalaCompatVersion> 
        <scalaVersion>${scala.version}</scalaVersion> 
        <scalaVersion>${scala.version}</scalaVersion> 
        <args> 
         <arg>-target:jvm-1.8</arg> 
        </args> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-surefire-plugin</artifactId> 
       <version>2.7</version> 
       <configuration> 
        <skipTests>true</skipTests> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.scalatest</groupId> 
       <artifactId>scalatest-maven-plugin</artifactId> 
       <version>1.0</version> 
       <configuration> 
        <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory> 
        <junitxml>.</junitxml> 
        <filereports>WDF TestSuite.txt</filereports> 
       </configuration> 
       <executions> 
        <execution> 
         <id>test</id> 
         <goals> 
          <goal>test</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 
    <reporting> 
     <plugins> 
      <plugin> 
       <groupId>org.scala-tools</groupId> 
       <artifactId>maven-scala-plugin</artifactId> 
       <configuration> 
        <scalaVersion>${scala.version}</scalaVersion> 
       </configuration> 
      </plugin> 
     </plugins> 
    </reporting> 
</project> 

मैं बाहर क्या याद आ रही है? धन्यवाद

उत्तर

22

ऐसा लगता है कि आपकी समस्या एक jar-with-dependencies, जो अक्का के साथ समस्याओं का कारण बनता में documentation में वर्णित के रूप bundling है,:

चेतावनी

अक्का के विन्यास दृष्टिकोण धारणा पर काफी निर्भर करता प्रत्येक मॉड्यूल/जार की अपनी संदर्भ.कॉफ़ फ़ाइल है, इन सभी को कॉन्फ़िगरेशन और लोड किया जाएगा। दुर्भाग्य से इसका यह भी अर्थ है कि यदि आप एक ही जार में एकाधिक जार डालते/विलय करते हैं, तो आपको सभी संदर्भ.कॉन्फ़ को मर्ज करने की आवश्यकता होती है। अन्यथा सभी डिफ़ॉल्ट खो जाएंगे और अक्का काम नहीं करेगा।

एक ही पृष्ठ पर सुझाव के रूप में, आप maven-shade-plugin उपयोग कर सकते हैं सभी संदर्भ विन्यास विलय करने के लिए:

आप अपने आवेदन पैकेज Maven का उपयोग कर रहे हैं, तो आप भी अपाचे Maven शेड का उपयोग कर सकते संसाधन ट्रांसफॉर्मर्स के लिए प्लगइन समर्थन बिल्ड क्लासपाथ पर सभी संदर्भ.कॉन्फ़ को मर्ज करने के लिए।

यह भी देखें: Akka: missing akka.version

+0

क्या किसी को परियोजना में संदर्भ.conf स्पष्ट रूप से जोड़ने की आवश्यकता है? – Marin

23

एक simular मुद्दा था:

<plugin> 
    <artifactId>maven-shade-plugin</artifactId> 
    <version>2.4.1</version> 
    <executions> 
    <execution> 
     <phase>package</phase> 
     <goals> 
     <goal>shade</goal> 
     </goals> 
     <configuration> 
     <transformers> 
      <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> 
      <resource>reference.conf</resource> 
      </transformer> 
     </transformers> 
     </configuration> 
    </execution> 
    </executions> 
</plugin> 
+1

धन्यवाद, आप ट्रांसफॉर्मर ने भी मेरे लिए काम किया। –

+4

आपकी प्लगइन अभी भी मुझे 'akka.version' कुंजी के लिए कोई कॉन्फ़िगरेशन सेटिंग नहीं मिली है, जैसा कि अक्का दस्तावेज़ में प्लगइन करता है। –

0

अकेले AppendingTransformer जोड़ा जा रहा है इस मुद्दे को हल नहीं किया:

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

एक जोड़कर ट्रांसफार्मर को जोड़ने के साथ यह हल मेरे लिए। यदि आप ईएमआर पर अपने स्पार्क एप्लिकेशन को तैनात करने की कोशिश कर रहे हैं और अभी भी इस मुद्दे का सामना कर रहे हैं तो कृपया मेरे समाधान here पर एक नज़र डालें। आशा करता हूँ की ये काम करेगा!

संबंधित मुद्दे