gpt4 book ai didi

java - 可运行 jar : lucene problems 中的 ElasticSearch

转载 作者:行者123 更新时间:2023-11-30 06:55:39 25 4
gpt4 key购买 nike

我正在尝试使用 maven 创建一个胖可执行 jar,包括将 elasticsearch 作为一个依赖项来为正在运行的 elasticsearch 节点创建一个 TransportClient。从 Eclipse 客户端连接到节点很好,但是当我从整个项目创建一个 jar 并使用 java -jar bla.jar 运行它时,连接失败并显示:

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]

的根本原因是名称为“Lucene50”的 org.apache.lucene.codecs.PostingsFormat 类型的 SPI 类不存在。您需要将支持此 SPI 的相应 JAR 文件添加到您的类路径中。当前类路径支持以下名称:[es090, completion090, XBloomFilter]。我读了这个,它基本上意味着我的最终 jar 包含来自各种 lucene 依赖项的同名 list 文件,这些文件被彼此覆盖。我使用带有 list 资源转换器的 maven-shade-plugin 来解决问题,但错误仍然存​​在:

<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>

然后我找了没有lucene依赖的elasticsearch jar,我只是想创建一个用于通信的transportclient。没有这样的运气,只有那个 jar ,包括lucene。我该怎么做才能将 elasticsearch 放入可运行的 jar 中?或者我应该将所有依赖项保存在 jar 之外的 lib 文件夹中?我不知道如何告诉 maven 这样做

--

更新:当我从 eclipse 导出对话框中使用“将所需的库复制到 jar 之外的子文件夹中”时,它起作用了。我让 eclipse 从中生成一个 build.xml,但我仍然想尝试使用 maven 来构建该 jar,无论是包含依赖项还是作为额外目录。

最佳答案

您应该添加以下内容 transformer标记到阴影插件。

<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>

关于java - 可运行 jar : lucene problems 中的 ElasticSearch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35066597/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com