问题描述
我正在尝试用maven创建一个胖可执行的jar,包括弹性搜索作为一个依赖关系来创建一个运行的弹性搜索节点的TransportClient。从eclipse中,客户端连接到节点,但是当我从整个项目创建一个jar并且使用 java -jar bla.jar
运行时,连接失败: DEBUG - [Armor]添加地址[{#transport#-1} {127.0.0.1} {127.0.0.1:9300 }]
DEBUG - [Armor]连接到节点[{#transport#-1} {127.0.0.1} {127.0.0.1:9300}]
INFO - [Armor]无法获取节点信息{#transport#-1} {127.0.0.1} {127.0.0.1:9300},断开连接...
org.elasticsearch.transport.RemoteTransportException:[无法反序列化类型[org.elasticsearch.action]的响应。 admin.cluster.node.liveness.LivenessResponse]]
导致:org.elasticsearch.transport.TransportSerializationException:无法反序列化类型[org.elasticsearch.action.admin.cluster.node.liveness.LivenessResponse]的响应$
在org.elasticsearch.transport.netty.MessageChannelHandler.handleResponse(MessageChannelHandler.java:179)〜[cmd-0.0.1-SNAPSHOT.jar :?]
在org.elastic search.transportweb :70)〜[cmd-0.0.1-SNAPSHOT.jar :?]
在org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)〜[cmd-0.0.1-SNAPSHOT。 jar:?]
在org.jboss.netty.channel.DefaultChannelPipeline $ DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)〜[cmd-0.0.1-SNAPSHOT.jar :?]
在org。 jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)〜[cmd-0.0.1-SNAPSHOT.jar :?]
在org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived (FrameDecoder.java:462)〜[cmd-0.0.1-SNAPSHOT.jar :?]
在org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:443)〜[ cmd-0.0.1-SNAPSHOT.jar:?]
在org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived (FrameDecoder.java:303)〜[cmd-0.0.1-SNAPSHOT.jar :?]
在org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)〜[cmd-0.0。 1-SNAPSHOT.jar :?]
在org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)〜[cmd-0.0.1-SNAPSHOT.jar :?]
在org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)〜[cmd-0.0.1-SNAPSHOT.jar :?]
在org.jboss.netty.channel.Channels.fireMessageReceived(Channels .java:268)〜[cmd-0.0.1-SNAPSHOT.jar:?]
在org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)〜[cmd-0.0.1- SNAPSHOT.jar:?]
在org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88)〜[cmd-0.0.1-SNAPSHOT.jar :?]
在org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)〜[cmd-0.0.1-SNAPSHOT.jar :?]
在org.jboss.netty.channel .socket.nio.AbstractNioSelector.run(AbstractNioSelector .java:337)〜[cmd-0.0.1-SNAPSHOT.jar :?]
在org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)〜[cmd- 0.0.1-SNAPSHOT.jar:?]
在org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)〜[cmd-0.0.1-SNAPSHOT.jar:? ]
在org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)〜[cmd-0.0.1-SNAPSHOT.jar:?]
在org.jboss.netty.util .internal.DeadLockProofWorker $ 1.run(DeadLockProofWorker.java:42)〜[cmd-0.0.1-SNAPSHOT.jar :?]
在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)〜 [?:1.8.0_66-internal]
在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)〜[?:1.8.0_66-internal]
在java.lang .Thread.run(Thread.java:745)〜[?:1.8.0_66-internal]
...
导致:java.lang.IllegalArgumentException:类型为org.apache的SPI类。名称为Lucene50的lucene.codecs.PostingsFormat不存在。您需要将支持此SPI的相应JAR文件添加到您的类路径中。当前类路径支持以下名称:org.apache.lucene.util.NamedSPILoader.lookup(NamedSPILoader.java:109)中的[es090,completion090,XBloomFilter]
〜[cmd-0.0.1-SNAPSHOT.jar: ?]
在org.apache.lucene.codecs.PostingsFormat.forName(PostingsFormat.java:112)〜[cmd-0.0.1-SNAPSHOT.jar:?]
在org.elasticsearch.common。 lucene.Lucene。< clinit>(Lucene.java:68)〜[cmd-0.0.1-SNAPSHOT.jar :?]
在org.elasticsearch.Version.fromId(Version.java:508)〜[ cmd-0.0.1-SNAPSHOT.jar:?]
在org.elasticsearch.Version.readVersion(Version.java:280)〜[cmd-0.0.1-SNAPSHOT.jar :?]
at org.elasticsearch.cluster.node.DiscoveryNode.readFrom(DiscoveryNode.java:327)〜[cmd-0.0.1-SNAPSHOT.jar :?]
在org.elasticsearch.cluster.node.DiscoveryNode.readNode(DiscoveryNode .java:310)〜[cmd-0.0.1-SNAPSHOT.jar :?]
在org.elasticsearch.action.admin.cluster.node.liveness.LivenessResponse.readFrom(LivenessResponse.java:52)〜[ cmd-0.0.1-SNAPSHOT.jar :?]
在org.elastics earch.transportweb :138)〜[cmd-0.0.1-SNAPSHOT.jar:?]
在org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)〜[cmd-0.0.1-SNAPSHOT。 jar:?]
在org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)〜[cmd-0.0.1-SNAPSHOT.jar :?]
在org.jboss。 netty.channel.DefaultChannelPipeline $ DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)〜[cmd-0.0.1-SNAPSHOT.jar:?]
在org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java :296)〜[cmd-0.0.1-SNAPSHOT.jar:?]
在org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:462)〜[cmd-0.0。 1-SNAPSHOT.jar:?]
在org.jboss.netty.handler.codec.frame.FrameDeco der.callDecode(FrameDecoder.java:443)〜[cmd-0.0.1-SNAPSHOT.jar :?]
在org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303 )〜[cmd-0.0.1-SNAPSHOT.jar :?]
在org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)〜[cmd-0.0.1-SNAPSHOT.jar: ?]
在org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)〜[cmd-0.0.1-SNAPSHOT.jar:?]
在org.jboss.netty。 channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)〜[cmd-0.0.1-SNAPSHOT.jar :?]
在org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)〜 [cmd-0.0.1-SNAPSHOT.jar :?]
在org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)〜[cmd-0.0.1-SNAPSHOT.jar :?]
在org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88)〜[cmd-0.0.1-SNAPSHOT.jar :?]
在org.jboss。 netty.channel.socket.nio.AbstractNioWorker.process(分区:Abst ractNioWorker.java:108)〜[cmd-0.0.1-SNAPSHOT.jar:?]
在org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337)〜[cmd -0.0.1-SNAPSHOT.jar:?]
在org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)〜[cmd-0.0.1-SNAPSHOT.jar: ?]
在org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)〜[cmd-0.0.1-SNAPSHOT.jar:?]
在org。 jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)〜[cmd-0.0.1-SNAPSHOT.jar :?]
在org.jboss.netty.util.internal.DeadLockProofWorker $ 1.run DeadLockProofWorker.java:42)〜[cmd-0.0.1-SNAPSHOT.jar :?]
在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)〜[?:1.8.0_66-内部]
在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)〜[?:1.8.0_66-internal]
在java.lang.Thread.run(Thread.java :745)〜[?:1.8.0_66-internal]
的名称为Lucene50的类型为org.apache.lucene.codecs.PostingsFormat的SPI类不存在。您需要将支持此SPI的相应JAR文件添加到您的类路径中。当前的类路径支持以下名称:[es090,completion090,XBloomFilter]
。我读到这一点,它基本上意味着我的最终的jar包含来自各种lucene依赖项的相同命名的清单文件,被彼此覆盖。我使用maven-shade-plugin与manifest资源转换器来解决问题,但错误仍然存在:
< build> ;
< plugins>
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-shade-plugin< / artifactId>
< version> 2.4.3< / version>
<执行>
< execution>
< phase> package< / phase>
< goals>
< goal> shade< / goal>
< / goals>
< configuration>
<变压器>
< transformer
implementation =org.apache.maven.plugins.shade.resource.ManifestResourceTransformer>
< mainClass> de.test.cmd.Main< / mainClass>
< / transformer>
< / transformers>
< / configuration>
< / execution>
< / executions>
< / plugin>
< / plugins>
< / build>
然后我找到了没有lucene依赖性的弹性搜索jar,我只是想创建一个用于通信的传输客户端。没有这样的运气,只有一个罐子,包括lucene。我可以做什么把弹性材料放入一个可运行的罐子?还是应该把所有依赖项保存在jar文件夹以外的其他文件夹中?我不知道如何告诉maven这样做
-
更新:当我使用将所需的库复制到除jar之外的子文件夹中,从eclipse导出对话框中,它可以正常工作。我让eclipse从那里生成一个build.xml,但是我仍然想尝试使用maven来构建该jar,包含依赖项,或者作为一个额外的目录。
您应该将以下变压器
标签添加到阴影插件中。
< transformer implementation =org.apache.maven.plugins.shade.resource.ServicesResourceTransformer/>
I am trying to create a fat executable jar with maven, including elasticsearch as a dependency to create a TransportClient to a running elasticsearch node. From eclipse the client connects just fine to the node, but when I create a jar from the whole project and run that with java -jar bla.jar
, the connection fails with:
DEBUG - [Armor] adding address [{#transport#-1}{127.0.0.1}{127.0.0.1:9300}]
DEBUG - [Armor] connected to node [{#transport#-1}{127.0.0.1}{127.0.0.1:9300}]
INFO - [Armor] failed to get node info for {#transport#-1}{127.0.0.1}{127.0.0.1:9300}, disconnecting...
org.elasticsearch.transport.RemoteTransportException: [Failed to deserialize response of type [org.elasticsearch.action.admin.cluster.node.liveness.LivenessResponse]]
Caused by: org.elasticsearch.transport.TransportSerializationException: Failed to deserialize response of type [org.elasticsearch.action.admin.cluster.node.liveness.LivenessResponse]
at org.elasticsearch.transport.netty.MessageChannelHandler.handleResponse(MessageChannelHandler.java:179) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.elasticsearch.transport.netty.MessageChannelHandler.messageReceived(MessageChannelHandler.java:138) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:462) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:443) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[?:1.8.0_66-internal]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[?:1.8.0_66-internal]
at java.lang.Thread.run(Thread.java:745) ~[?:1.8.0_66-internal]
...
Caused by: java.lang.IllegalArgumentException: An SPI class of type org.apache.lucene.codecs.PostingsFormat with name 'Lucene50' does not exist. You need to add the corresponding JAR file supporting this SPI to your classpath. The current classpath supports the following names: [es090, completion090, XBloomFilter]
at org.apache.lucene.util.NamedSPILoader.lookup(NamedSPILoader.java:109) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.apache.lucene.codecs.PostingsFormat.forName(PostingsFormat.java:112) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.elasticsearch.common.lucene.Lucene.<clinit>(Lucene.java:68) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.elasticsearch.Version.fromId(Version.java:508) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.elasticsearch.Version.readVersion(Version.java:280) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.elasticsearch.cluster.node.DiscoveryNode.readFrom(DiscoveryNode.java:327) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.elasticsearch.cluster.node.DiscoveryNode.readNode(DiscoveryNode.java:310) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.elasticsearch.action.admin.cluster.node.liveness.LivenessResponse.readFrom(LivenessResponse.java:52) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.elasticsearch.transport.netty.MessageChannelHandler.handleResponse(MessageChannelHandler.java:177) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.elasticsearch.transport.netty.MessageChannelHandler.messageReceived(MessageChannelHandler.java:138) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:462) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:443) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42) ~[cmd-0.0.1-SNAPSHOT.jar:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[?:1.8.0_66-internal]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[?:1.8.0_66-internal]
at java.lang.Thread.run(Thread.java:745) ~[?:1.8.0_66-internal]
With the root cause of An SPI class of type org.apache.lucene.codecs.PostingsFormat with name 'Lucene50' does not exist. You need to add the corresponding JAR file supporting this SPI to your classpath. The current classpath supports the following names: [es090, completion090, XBloomFilter]
. I read up on this, it basically means that my final jar includes same-named manifest files from the various lucene dependencies, that are overwritten by each other. I used the maven-shade-plugin with a manifest resource transformer to solve the problem, but the error remains:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>de.test.cmd.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Then I looked for elasticsearch jars without lucene dependency, I just want to create a transportclient for communication. No such luck, there is only that one jar, including lucene. What can I do to put elasticsearch into a runnable jar? or should I keep all dependencies in a lib folder besides the jar? I don't know how to tell maven to do that
--
UPDATE: When I use "Copy required libraries into a sub-folder besides the jar" from eclipse export dialog, it works. I let eclipse generate a build.xml from that, but I still want to try and use maven for building that jar, either with dependencies included, or as an extra directory.
You should add the follow transformer
tag to the shade plugin.
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
这篇关于弹性搜索在一个可运行的jar:lucene问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!