在elasticsearch 5.3.0 java api中打破变化

时间:2017-04-06 20:02:24

标签: java elasticsearch netty elasticsearch-5

我将弹性搜索从2.3.4升级到5.3.0

以下是我的类路径中的jar

elasticsearch-5.3.0.jar
HdrHistogram-2.1.6.jar
hppc-0.7.1.jar
jackson-core-2.8.6.jar
jackson-dataformat-cbor-2.8.6.jar
jackson-dataformat-smile-2.8.6.jar
jackson-dataformat-yaml-2.8.6.jar
java-version-checker-5.3.0.jar
jna-4.2.2.jar
joda-time-2.9.5.jar
jopt-simple-5.0.2.jar
jts-1.13.jar
lucene-analyzers-common-6.4.1.jar
lucene-backward-codecs-6.4.1.jar
lucene-core-6.4.1.jar
lucene-grouping-6.4.1.jar
lucene-highlighter-6.4.1.jar
lucene-join-6.4.1.jar
lucene-memory-6.4.1.jar
lucene-misc-6.4.1.jar
lucene-queries-6.4.1.jar
lucene-queryparser-6.4.1.jar
lucene-sandbox-6.4.1.jar
lucene-spatial-6.4.1.jar
lucene-spatial-extras-6.4.1.jar
lucene-spatial3d-6.4.1.jar
lucene-suggest-6.4.1.jar
securesm-1.1.jar
snakeyaml-1.15.jar
t-digest-3.0.jar
transport-netty4-client-5.3.0.jar
percolator-client-5.3.0.jar
reindex-client-5.3.0.jar
lang-mustache-client-5.3.0.jar
transport-netty3-client-5.3.0.jar
transport-5.3.0.jar
log4j-api-2.7.jar
log4j-core-2.7.jar
log4j-1.2-api-2.7.jar
spatial4j-0.6.jar

当我做

client = new PreBuiltTransportClient(Settings.EMPTY)
            .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("127.0.0.1"), 9300)) 

我得到以下异常

Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/netty/logging/InternalLoggerFactory
    at org.elasticsearch.transport.Netty3Plugin.<clinit>(Netty3Plugin.java:46)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.elasticsearch.plugins.PluginsService.loadPlugin(PluginsService.java:376)
    at org.elasticsearch.plugins.PluginsService.<init>(PluginsService.java:104)
    at org.elasticsearch.client.transport.TransportClient.newPluginService(TransportClient.java:101)
    at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:126)
    at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:268)
    at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:125)
    at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:111)
    at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:101)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
    at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:71)
    at org.codehaus.groovy.runtime.callsite.ConstructorSite.callConstructor(ConstructorSite.java:42)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
    at org.hire.test.HudkiES.openClient(HudkiES.groovy:146)
    at org.hire.test.HudkiES.<init>(HudkiES.groovy:113)
    at org.hire.test.HudkiES.<init>(HudkiES.groovy)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
    at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:71)
    at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:81)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
    at org.hire.test.HudkiES.main(HudkiES.groovy:1020)
Caused by: java.lang.ClassNotFoundException: org.jboss.netty.logging.InternalLoggerFactory
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 37 more

Java版本1.8

是否有人也面临同样的问题或知道我在这里失踪了什么?

1 个答案:

答案 0 :(得分:0)

Elasticsearch 5.3期待NettyPlugin org.elasticsearch.transport.Netty4Plugin的第4版。你很可能在你的类路径或两个版本上都有错误的版本,旧的版本首先被抓获。

如果为libs生成依赖关系树,则会看到哪些版本被拉入,然后可以包含/排除正确/错误的版本。