java.lang.NoSuchMethodError: org.elasticsearch.common.settings.Settings$Builder.put([Ljava/lang/Object;)

Hi,
I am upgrading from ES version 2.x to 6.4.2 and am getting this error while server startup. I am using spring boot version 2.0.5 and have included the 6.4.2 version of ES libraries.

	Settings settings = Settings.builder()
		.put("transport.ping_schedule", "5s")
		.put("cluster.name", clusterId)
		.put("request.headers.X-Found-Cluster", clusterId)
		.put("xpack.security.user", userPass)
		.build();

		return new PreBuiltXPackTransportClient(settings)
			.addTransportAddress(new TransportAddress(InetAddress.getByName(hostname), port));

Here is the detailed message:

	WARN 3714 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'myIncidentsService': Unsatisfied dependency expressed through field 'customerIncidentRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerIncidentRepository': Cannot resolve reference to bean 'elasticsearchTemplate' while setting bean property 'elasticsearchOperations'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'elasticsearchTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataAutoConfiguration.class]: Unsatisfied dependency expressed through method 'elasticsearchTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'client' defined in class path resource [com/gmp/bootes/elasticsearch/config/ElasticSearchConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.elasticsearch.client.Client]: Factory method 'client' threw exception; nested exception is java.lang.NoSuchMethodError: org.elasticsearch.common.settings.Settings$Builder.put([Ljava/lang/Object;)Lorg/elasticsearch/common/settings/Settings$Builder;

Any ideas? Happy to provide more information if required.
Thank you !
Kriss

The Settings.Builder.put(Object ... settings) method was removed in Elasticsearch 6.1.0

Something in your app is trying to call it, but it doesn't exist anymore.
My best guess is that you have a mix of different versions of ES jars in your application, but it's hard to diagnose anything from a spring error like that.

This method

    public Settings.Builder put(Settings settings) {
        return this.put(settings, true);
    }

seems to be present in

org.elasticsearch.common.settings.Settings class in the elasticsearch-6.4.2.jar ?

Am I missing something?

Thank you!!

A more basic question being, do you know if Elasticsearch 6.4.2 will work with the latest (or any) version of Spring Boot ?

Thank you again !!

Yes, this method exists

public Settings.Builder put(Settings settings)

but the signature in your error is:

org.elasticsearch.common.settings.Settings$Builder
.put(
[Ljava/lang/Object;
)
Lorg/elasticsearch/common/settings/Settings$Builder;

which is

public Settings.Builder put(Object ... settings)

And that method was removed in 6.1.0

The procedure for demangling the signature is:

  • The first part is the class that contains the method
  • Followed by a '.'
  • Then the name of the method
  • Then the arguments in brackets
  • Then the return type

For the return type & argument types,

  • [ indicates an array
  • L indicates a class, with the class name immediately following terminated with ';'
  • Class names use '/' rather than '.' for their hierarchy.

So [Ljava/lang/Object; is java.lang.Object[]

I cannot see why it wouldn't be.

Have you actually checked whether you have consistent versions of the ES jars on your classpath?

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