Hi,
I am building a very basic spring app using java elasticsearch high level client. I have following elastic search dependency in build.gradle.
compile 'org.elasticsearch.client:elasticsearch-rest-high-level-client:6.4.1'
elastic search cluster version: 6.4.0
On server startup I am getting following exception. I think this is happening because rest client dependency in maven is of type 'pom'. Am I missing any any other dependencies? Thanks in advance for the help.
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.elasticsearch.client.RestHighLevelClient]: Factory method 'client' threw exception; nested exception is java.lang.NoClassDefFoundError: org/elasticsearch/common/xcontent/DeprecationHandler
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:582) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
... 46 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/elasticsearch/common/xcontent/DeprecationHandler
at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_152]
at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[na:1.8.0_152]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_152]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) ~[na:1.8.0_152]
at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0_152]
at java.net.URLClassLoader$1.run(URLClassLoader.java:368) ~[na:1.8.0_152]
at java.net.URLClassLoader$1.run(URLClassLoader.java:362) ~[na:1.8.0_152]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_152]
at java.net.URLClassLoader.findClass(URLClassLoader.java:361) ~[na:1.8.0_152]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_152]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) ~[na:1.8.0_152]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_152]
at org.elasticsearch.client.RestHighLevelClient.<clinit>(RestHighLevelClient.java:1429) ~[elasticsearch-rest-high-level-client-6.4.1.jar:5.6.10]
at com.alef.audittrail.persistence.SpringConfig.client(SpringConfig.java:22) ~[classes/:na]
at com.alef.audittrail.persistence.SpringConfig$$EnhancerBySpringCGLIB$$2e6a8f2.CGLIB$client$0(<generated>) ~[classes/:na]
at com.alef.audittrail.persistence.SpringConfig$$EnhancerBySpringCGLIB$$2e6a8f2$$FastClassBySpringCGLIB$$9eed9939.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 com.alef.audittrail.persistence.SpringConfig$$EnhancerBySpringCGLIB$$2e6a8f2.client(<generated>) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_152]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_152]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_152]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_152]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
... 47 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.elasticsearch.common.xcontent.DeprecationHandler
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_152]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_152]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) ~[na:1.8.0_152]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_152]
... 71 common frames omitted
In gradle dependecies tree I can see following dependencies
+--- org.elasticsearch.client:elasticsearch-rest-high-level-client:6.4.1
| +--- org.elasticsearch:elasticsearch:6.4.1
| | +--- org.elasticsearch:elasticsearch-core:6.4.1
| | +--- org.elasticsearch:elasticsearch-secure-sm:6.4.1
| | +--- org.elasticsearch:elasticsearch-x-content:6.4.1
| | | +--- org.elasticsearch:elasticsearch-core:6.4.1
| | | +--- org.yaml:snakeyaml:1.17 -> 1.19
| | | +--- com.fasterxml.jackson.core:jackson-core:2.8.10 -> 2.9.6
| | | +--- com.fasterxml.jackson.dataformat:jackson-dataformat-smile:2.8.10 -> 2.9.6
| | | +--- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.8.10 -> 2.9.6
| | | \--- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:2.8.10 -> 2.9.6
| | +--- org.apache.lucene:lucene-core:7.4.0
| | +--- org.apache.lucene:lucene-analyzers-common:7.4.0
| | +--- org.apache.lucene:lucene-backward-codecs:7.4.0
| | +--- org.apache.lucene:lucene-grouping:7.4.0
| | +--- org.apache.lucene:lucene-highlighter:7.4.0
| | +--- org.apache.lucene:lucene-join:7.4.0
| | +--- org.apache.lucene:lucene-memory:7.4.0
| | +--- org.apache.lucene:lucene-misc:7.4.0
| | +--- org.apache.lucene:lucene-queries:7.4.0
| | +--- org.apache.lucene:lucene-queryparser:7.4.0
| | +--- org.apache.lucene:lucene-sandbox:7.4.0
| | +--- org.apache.lucene:lucene-spatial:7.4.0
| | +--- org.apache.lucene:lucene-spatial-extras:7.4.0
| | +--- org.apache.lucene:lucene-spatial3d:7.4.0
| | +--- org.apache.lucene:lucene-suggest:7.4.0
| | +--- org.elasticsearch:elasticsearch-cli:6.4.1
| | | +--- net.sf.jopt-simple:jopt-simple:5.0.2
| | | \--- org.elasticsearch:elasticsearch-core:6.4.1
| | +--- com.carrotsearch:hppc:0.7.1
| | +--- joda-time:joda-time:2.10 -> 2.9.9
| | +--- com.tdunning:t-digest:3.2
| | +--- org.hdrhistogram:HdrHistogram:2.1.9
| | +--- org.apache.logging.log4j:log4j-api:2.11.1 -> 2.10.0
| | \--- org.elasticsearch:jna:4.5.1
| +--- org.elasticsearch.client:elasticsearch-rest-client:6.4.1