title: After Spring Data ES migration : IllegalArgumentException: NamedWriteable is already registered for [...], cannot register [...]
body: <p>I have a spring application (that's part of spring discovery cluster as discovery client). We have chosen to migrate this app from spring data elasticsearch 2.1.1.RELEASE (link to a dockerise 2.4.3-alpine elasticsearch) to SDE 3.0.14.RELEASE (that can be linked, if i'm correct, with a dockerise ES 5.5.0-alpine). My problem is that this app never achieve to start. </p>
  
  <p>NOTE: It was perfectly working before the migration </p>
  
  <p>First, I thought it was a trouble with maven dependencies, so I tried to find duplicate dependancies but I didn't have result.
  I also tried to use a own TransportClient (with erasing app properties to prevent spring autoconfiguration), like Elasticsearch documentation describes (but apparently, spring should be able to do it itself). </p>
  
  <p>Here's main class (with some, maybe useful, spring annotations):</p>
  
  <pre class="lang-java prettyprint-override"><code>@SpringBootApplication
  @EnableDiscoveryClient
  @EnableFeignClients
  @EnableConfigurationProperties
  @Configuration
  @EnableElasticsearchRepositories(basePackages = {"com.sap.testreportservice"}, repositoryBaseClass = ApplicationRepositoryImpl.class)
  public class TestreportServiceApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(TestreportServiceApplication.class, args);
      }
  }
  </code></pre>
  
  <p>Here's its maven dependancies:</p>
  
  <pre class="lang-xml prettyprint-override"><code>
  &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
              &lt;artifactId&gt;spring-cloud-starter-stream-rabbit&lt;/artifactId&gt;
          &lt;version&gt;1.2.0.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;io.springfox&lt;/groupId&gt;
              &lt;artifactId&gt;springfox-swagger2&lt;/artifactId&gt;
              &lt;version&gt;2.6.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;io.springfox&lt;/groupId&gt;
              &lt;artifactId&gt;springfox-swagger-ui&lt;/artifactId&gt;
              &lt;version&gt;2.6.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
              &lt;artifactId&gt;spring-cloud-netflix-hystrix-stream&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
              &lt;artifactId&gt;spring-cloud-starter-zuul&lt;/artifactId&gt;
              &lt;version&gt;1.4.7.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
              &lt;artifactId&gt;spring-cloud-starter-netflix-eureka-client&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
              &lt;artifactId&gt;spring-data-elasticsearch&lt;/artifactId&gt;
              &lt;version&gt;3.0.14.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.elasticsearch&lt;/groupId&gt;
              &lt;artifactId&gt;elasticsearch&lt;/artifactId&gt;
              &lt;version&gt;5.5.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
              &lt;artifactId&gt;spring-cloud-starter-openfeign&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.json&lt;/groupId&gt;
              &lt;artifactId&gt;json&lt;/artifactId&gt;
              &lt;version&gt;20190722&lt;/version&gt;
              &lt;scope&gt;compile&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
  </code></pre>
  
  <p>Here's some app properties:</p>
  
  <pre><code>spring:
    data:
      elasticsearch:
        cluster-name: ${ES_CLUSTER_NAME:insights}
        cluster-nodes: ${ES_CLUSTER_NODES:localhost:9300}
  </code></pre>
  
  <p>Here's my custom Transport Client:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Configuration
  public class ElasticsearchConfig {
  
      @Bean
      Client client() {
          Settings settings = Settings.builder()
                  .put("cluster.name", "insights")
                  .build();
          TransportClient client = new PreBuiltTransportClient(settings);
          try {
              client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
          } catch (UnknownHostException e) {
              e.printStackTrace();
          }
          return client;
      }
  }
  </code></pre>
  
  <p>Here's some log extract (ask me for the complete stacktrace)</p>
  
  <pre><code>
  Caused by: java.lang.IllegalArgumentException: NamedWriteable [org.elasticsearch.index.query.QueryBuilder][parent_id] is already registered for [org.elasticsearch.search.SearchModule$$Lambda$942/734191650], cannot register [org.elasticsearch.join.ParentJoinPlugin$$Lambda$952/956934228]
      at org.elasticsearch.common.io.stream.NamedWriteableRegistry.&lt;init&gt;(NamedWriteableRegistry.java:91) ~[elasticsearch-5.5.0.jar:5.5.0]
      at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:148) ~[elasticsearch-5.5.0.jar:5.5.0]
      at org.elasticsearch.client.transport.TransportClient.&lt;init&gt;(TransportClient.java:254) ~[elasticsearch-5.5.0.jar:5.5.0]
      at org.springframework.data.elasticsearch.client.TransportClientFactoryBean$SpringDataTransportClient.&lt;init&gt;(TransportClientFactoryBean.java:234) ~[spring-data-elasticsearch-3.0.14.RELEASE.jar:3.0.14.RELEASE]
      at org.springframework.data.elasticsearch.client.TransportClientFactoryBean.buildClient(TransportClientFactoryBean.java:103) ~[spring-data-elasticsearch-3.0.14.RELEASE.jar:3.0.14.RELEASE]
      at org.springframework.data.elasticsearch.client.TransportClientFactoryBean.afterPropertiesSet(TransportClientFactoryBean.java:98) ~[spring-data-elasticsearch-3.0.14.RELEASE.jar:3.0.14.RELEASE]
      at org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration.elasticsearchClient(ElasticsearchAutoConfiguration.java:59) ~[spring-boot-autoconfigure-2.1.7.RELEASE.jar:2.1.7.RELEASE]
      at org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration$$EnhancerBySpringCGLIB$$151bff6d.CGLIB$elasticsearchClient$0(&lt;generated&gt;) ~[spring-boot-autoconfigure-2.1.7.RELEASE.jar:2.1.7.RELEASE]
      at org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration$$EnhancerBySpringCGLIB$$151bff6d$$FastClassBySpringCGLIB$$575694c9.invoke(&lt;generated&gt;) ~[spring-boot-autoconfigure-2.1.7.RELEASE.jar:2.1.7.RELEASE]
      at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.1.9.RELEASE.jar:5.1.9.RELEASE]
      at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
      at org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration$$EnhancerBySpringCGLIB$$151bff6d.elasticsearchClient(&lt;generated&gt;) ~[spring-boot-autoconfigure-2.1.7.RELEASE.jar:2.1.7.RELEASE]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
      at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
      at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
      ... 145 common frames omitted
  
  
  </code></pre>