I have upgraded my spring boot from 2.2.6.RELEASE to 2.7.0. After the upgrade , i am getting ClassNotFoundException when i start the application. I tried with 2.6.6 but result is same.
My pom file looks like
<dependency> <groupId>io.projectreactor.netty</groupId> <artifactId>reactor-netty</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webflux</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-elasticsearch</artifactId> </dependency>
Exception :
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reactiveElasticsearchClient' defined in class path resource [org/springframework/boot/autoconfigure/data/elasticsearch/ReactiveElasticsearchRestClientAutoConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.data.elasticsearch.client.reactive.DefaultReactiveElasticsearchClient] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@3b192d32] org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.0.jar:2.7.0] Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.data.elasticsearch.client.reactive.DefaultReactiveElasticsearchClient] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@3b192d32] org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[spring-beans-5.3.20.jar:5.3.20] ... 15 common frames omitted Caused by: java.lang.NoClassDefFoundError: org/elasticsearch/xcontent/XContentParser ..... at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:467) ~[spring-core-5.3.20.jar:5.3.20] ... 22 common frames omitted Caused by: java.lang.ClassNotFoundException: org.elasticsearch.xcontent.XContentParser at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583) ~[na:na] at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[na:na] ... 26 common frames omitted
Can anyone please help on this?
Advertisement
Answer
Finally i could solve the issue. In the parent pom had elastic search version was given explicitly. Once i remove the given version error has gone and application works fine.