2016-10-17 13 views
0

Intelli Idea Java IDEからElasticSearch 2.4クライアントが正常に動作します。同じコードをjarファイルjava -jar <jar-path>で実行すると、次のエラーが発生します。ElasticSearch 2.4:IDEでうまく動作しますが、JARとしては機能しません。

Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{<remote-ip>}{<remote-ip>:9300}]] at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:290) at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:207) at org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55) at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:288) at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:359) at org.elasticsearch.client.support.AbstractClient$IndicesAdmin.execute(AbstractClient.java:1226) at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:86) at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:56) at com.creo.datawarehouse.es.op.imp.IndexOperationImp.createIndex(IndexOperationImp.java:66) at com.creo.datawarehouse.es.ElasticSearch.initialise(ElasticSearch.java:27) at com.creo.datawarehouse.script.App.main(App.java:37)

POMの依存関係:

<dependency> <groupId>org.elasticsearch</groupId> <artifactId>elasticsearch</artifactId> <version>2.4.0</version> </dependency>

This question任意の答えとwhat is the jar version for 2.4.0 ES version in this questionを持っていません。

可能性のある理由や解決方法を教えてください。

答えて

0

最後に、数時間のデバッグ後、解決策が見つかりました。それらに言及する前に、簡単なキーノート。


  1. ELSサーバが2.4.1であれば、Mavenのjarファイルも2.4.1
  2. (本から見つけ)詳細で、よりログのlog4jの依存関係を追加する必要があります。
  3. プラグインセクションに陰影を追加します。
  4. IDEとは何も関係ありません(最初に実行されるかもしれませんが、prodを実行するには上記に従ってください)。

しかし、なぜIDEで実行されていたのですか?


のJava Mavenの依存関係

<dependency> 
     <groupId>org.elasticsearch</groupId> 
     <artifactId>elasticsearch</artifactId> 
     <version>2.4.1</version> 
    </dependency> 

     <dependency> 
      <groupId>log4j</groupId> 
      <artifactId>log4j</artifactId> 
      <version>1.2.17</version> 
     </dependency> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-api</artifactId> 
      <version>1.7.5</version> 
     </dependency> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-log4j12</artifactId> 
      <version>1.7.5</version> 
     </dependency> 
     <build> 
     <plugins> 
     [---] 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <version>2.5.4</version> 
      <configuration> 
       <finalName>injector-2.4.1</finalName> 
       <appendAssemblyId>false</appendAssemblyId> 
       <descriptorRefs> 
       <descriptorRef>jar-with-dependencies</descriptorRef> 
       </descriptorRefs> 
       <archive> 
       <manifest> 
        <mainClass>org.elasticsearch.demo.workshop.injector.runner.Generate</mainClass> 
       </manifest> 
       </archive> 
      </configuration> 
      <executions> 
       <execution> 
       <phase>package</phase> 
       <goals> 
        <goal>single</goal> 
       </goals> 
       </execution> 
      </executions> 
      </plugin> 

      <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <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.ManifestResourceTransformer"> 
         <mainClass>com.your.classss.App</mainClass> 
        </transformer> 
        </transformers> 
       </configuration> 
       </execution> 
      </executions> 
      </plugin> 
      [--] 
     </plugins> 
    </build> 
関連する問題