三人行必有我师

x-pack java client 方式访问elasticsearch5.1.1集群出现异常

Elasticsearch | 作者 spider | 发布于2017年01月26日 | 阅读数:7084

elasticsearch5.1.1集群

Settings settings = Settings.builder().put("cluster.name", "cluster")
                .put("xpack.security.user", "transport_client_user:changeme").build();
        TransportClient client = new PreBuiltXPackTransportClient(settings)
                .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("hadoop01"), 9300))
                .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("hadoop02"), 9300))
                .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("hadoop03"), 9300));
        List<DiscoveryNode> connectedNodes = client.connectedNodes();
        for (DiscoveryNode discoveryNode : connectedNodes) {
            System.out.println(discoveryNode.getId());
        }

异常:
Exception in thread "main" java.lang.VerifyError: class org.elasticsearch.xpack.XPackPlugin overrides final method onModule.(Lorg/elasticsearch/common/network/NetworkModule;)V
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.<init>(PreBuiltXPackTransportClient.java:50)
    at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.<init>(PreBuiltXPackTransportClient.java:46)
    at com.tm.demo.ElasticClient.main(ElasticClient.java:29)
已邀请:

kepmoving - 90后

赞同来自:

安装x-pack插件后,把elasticsearch plugins目录下的jar添加到项目里去,注意jar包冲突

要回复问题请先登录注册