복붙노트

[SPRING] 원인 : java.lang.ClassNotFoundException : org.elasticsearch.transport.Netty3Plugin

SPRING

원인 : java.lang.ClassNotFoundException : org.elasticsearch.transport.Netty3Plugin

나는 봄 부팅 2.0.3 릴리스를 사용하고 org.elasticsearch.client.Client를 인스턴스화하는 동안 문제가있다. 내 코드 :

Client client = new PreBuiltTransportClient(Settings.builder()
                .put("cluster.name", clustername)
                .build())
                .addTransportAddress(
new InetSocketTransportAddress(InetAddress.getByName(host), port)
);

이 코드는 다음과 같은 오류를줍니다.

Caused by: java.lang.NoClassDefFoundError: org/elasticsearch/transport/Netty3Plugin
at org.elasticsearch.transport.client.PreBuiltTransportClient.<clinit>(PreBuiltTransportClient.java:91) ~[transport-5.6.10.jar:5.6.10]
at kz.icode.idmatrix.config.ElasticsearchConfiguration.client(ElasticsearchConfiguration.java:56) ~[classes/:na]
at kz.icode.idmatrix.config.ElasticsearchConfiguration$$EnhancerBySpringCGLIB$$7e53ae93.CGLIB$client$0(<generated>) ~[classes/:na]
at kz.icode.idmatrix.config.ElasticsearchConfiguration$$EnhancerBySpringCGLIB$$7e53ae93$$FastClassBySpringCGLIB$$fef36179.invoke(<generated>) ~[classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at kz.icode.idmatrix.config.ElasticsearchConfiguration$$EnhancerBySpringCGLIB$$7e53ae93.client(<generated>) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_171]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
... 99 common frames omitted

org.elasticsearch : elasticsearch : 5.6.10 및 org.elasticsearch.client : client : 5.6.10을 사용합니다.

해결법

  1. ==============================

    1.spring-boot-startter-data-elasticsearch 만 추가하면 모든 종속성이 만족되는 것은 아닙니다.

    spring-boot-startter-data-elasticsearch 만 추가하면 모든 종속성이 만족되는 것은 아닙니다.

    나머지 모든 종속성을 명시 적으로 정의해야합니다.

        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>transport</artifactId>
            <version>${elasticsearch.version}</version>
        </dependency>
    
        <dependency>
            <groupId>org.elasticsearch.plugin</groupId>
            <artifactId>transport-netty4-client</artifactId>
            <version>${elasticsearch.version}</version>
        </dependency>
    

    부모를 선언했다면 대부분의 태그를 생략 할 수 있습니다.

  2. from https://stackoverflow.com/questions/51039938/caused-by-java-lang-classnotfoundexception-org-elasticsearch-transport-netty3p by cc-by-sa and MIT license