# org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: org.elasticsearch.action.index.IndexRequest.ifSeqNo()J

**URL:** <https://discuss.elastic.co/t/org-springframework-web-util-nestedservletexception-handler-dispatch-failed-nested-exception-is-java-lang-nosuchmethoderror-org-elasticsearch-action-index-indexrequest-ifseqno-j/176627>\
**Category:** Elasticsearch\
**Created:** [April 12, 2019, 12:53pm UTC](https://discuss.elastic.co/t/org-springframework-web-util-nestedservletexception-handler-dispatch-failed-nested-exception-is-java-lang-nosuchmethoderror-org-elasticsearch-action-index-indexrequest-ifseqno-j/176627 "2019-04-12T12:53:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![shash4243](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@shash4243](https://discuss.elastic.co/u/shash4243)\
**Post date:** [April 12, 2019, 12:53pm UTC](https://discuss.elastic.co/t/org-springframework-web-util-nestedservletexception-handler-dispatch-failed-nested-exception-is-java-lang-nosuchmethoderror-org-elasticsearch-action-index-indexrequest-ifseqno-j/176627/1 "2019-04-12T12:53:19Z")

</div>

Hi,

I am trying out RestHighLevelClient with spring boot. My current version is 2.1.1.RELEASE and these are my dependencies

```
	<dependency>
		<groupId>org.elasticsearch.client</groupId>
		<artifactId>elasticsearch-rest-high-level-client</artifactId>
		<version>7.0.0</version>
	</dependency>

	<dependency>
		<groupId>org.elasticsearch.client</groupId>
		<artifactId>transport</artifactId>
		<version>7.0.0</version>
	</dependency>

```

This is my code

elasticClient = new RestHighLevelClient(RestClient.builder(new HttpHost(env.getProperty("elastic.host"), 9200, "http")));

IndexRequest indexRequest = new IndexRequest("test")  
.id("1").type("\_doc").source(body, XContentType.JSON);

```
		elasticClient.index(indexRequest, RequestOptions.DEFAULT);

```

My Stacktrace:

org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: org.elasticsearch.action.index.IndexRequest.ifSeqNo()J  
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1053)  
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)  
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)  
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908)  
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)  
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)  
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)  
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)  
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)  
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)  
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)  
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)  
at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:90)  
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)  
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)  
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)  
at com.ngdesk.RequestResponseLoggingFilter.doFilter(RequestResponseLoggingFilter.java:319)  
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)  
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)  
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320)  
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)  
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)  
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)  
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119)  
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)  
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)  
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)  
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)  
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)  
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)  
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)  
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)  
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)  
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)  
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)  
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:74)  
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)  
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)  
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)  
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)  
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)  
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)  
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)

Please advice if I'm missing something or if im doing something wrong? what needs to change.

The same code works inside a maven application but inside spring boot it wont work.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 12, 2019, 1:11pm UTC](https://discuss.elastic.co/t/org-springframework-web-util-nestedservletexception-handler-dispatch-failed-nested-exception-is-java-lang-nosuchmethoderror-org-elasticsearch-action-index-indexrequest-ifseqno-j/176627/2 "2019-04-12T13:11:21Z")

</div>

When using @springboot 2.1+ with  
elasticsearch, you need to be explicit with some transitive dependencies as SpringBoot forces a version 6.4...

Basically add this to your project to workaround the problem

> <https://github.com/dadoonet/legacy-search/commit/ecf586f9f1b887354e975d3ecba36f1c7d010ba8>

Another way is documented at: [https://docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html#howto-customize-dependency-versions](https://docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html#howto-customize-dependency-versions)

You can put this in your `pom.xml`:

```auto
<properties>
  <elasticsearch.version>7.0.0<elasticsearch.version>
</properties>

```

---

<div class="post-metadata">

**Author:** ![snicoll](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/snicoll/32/20285_2.png) [@snicoll](https://discuss.elastic.co/u/snicoll)\
**Post date:** [April 15, 2019, 6:37am UTC](https://discuss.elastic.co/t/org-springframework-web-util-nestedservletexception-handler-dispatch-failed-nested-exception-is-java-lang-nosuchmethoderror-org-elasticsearch-action-index-indexrequest-ifseqno-j/176627/3 "2019-04-15T06:37:16Z")

</div>

Just to clarify a few things, Spring Boot does not force anything, it provides dependency management for a version of ElasticSearch. To make sure things are consistent and you don't end up with mixed version of elasticsearch modules, dependency management is provided for all modules.

As with everything in Spring Boot, if you choose to use dependency management and you don't want to use the version chosen by a Spring Boot generation you must set the relevant property (here `elasticsearch.version`). Alternatively, and in particular if you import the `spring-boot-dependencies` bom rather than extending from `spring-boot-parent`, you must provide dependency management for all modules rather than hardcoding the version of a couple of them as shown above. Doing this will force a version and left the default of other modules to `6.4`.

Another thing to point out is that this mechanism has nothing to do with Spring Boot 2.1 per se. It's just we started to support the high client and therefore provided dependency management for it.

---

<div class="post-metadata">

**Author:** ![shash4243](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@shash4243](https://discuss.elastic.co/u/shash4243)\
**Post date:** [April 15, 2019, 7:24am UTC](https://discuss.elastic.co/t/org-springframework-web-util-nestedservletexception-handler-dispatch-failed-nested-exception-is-java-lang-nosuchmethoderror-org-elasticsearch-action-index-indexrequest-ifseqno-j/176627/4 "2019-04-15T07:24:51Z")

</div>

Thank you that clarifies things.

---

<div class="post-metadata">

**Author:** ![shash4243](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@shash4243](https://discuss.elastic.co/u/shash4243)\
**Post date:** [April 15, 2019, 7:25am UTC](https://discuss.elastic.co/t/org-springframework-web-util-nestedservletexception-handler-dispatch-failed-nested-exception-is-java-lang-nosuchmethoderror-org-elasticsearch-action-index-indexrequest-ifseqno-j/176627/5 "2019-04-15T07:25:08Z")

</div>

Thanks it works now!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 13, 2019, 7:25am UTC](https://discuss.elastic.co/t/org-springframework-web-util-nestedservletexception-handler-dispatch-failed-nested-exception-is-java-lang-nosuchmethoderror-org-elasticsearch-action-index-indexrequest-ifseqno-j/176627/6 "2019-05-13T07:25:15Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
