# Elasticsearch 8 Java Client ResponseException status line \[HTTP/1.1 404 Not Found\] {"statusCode":404,"error":"Not Found","message":"Not Found"}

**URL:** <https://discuss.elastic.co/t/elasticsearch-8-java-client-responseexception-status-line-http-1-1-404-not-found-statuscode-404-error-not-found-message-not-found/316019>\
**Category:** Elasticsearch\
**Created:** [October 6, 2022, 10:40pm UTC](https://discuss.elastic.co/t/elasticsearch-8-java-client-responseexception-status-line-http-1-1-404-not-found-statuscode-404-error-not-found-message-not-found/316019 "2022-10-06T22:40:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Gattinger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_gattinger/32/99690_2.png) [@Michael\_Gattinger](https://discuss.elastic.co/u/Michael_Gattinger)\
**Post date:** [October 6, 2022, 10:40pm UTC](https://discuss.elastic.co/t/elasticsearch-8-java-client-responseexception-status-line-http-1-1-404-not-found-statuscode-404-error-not-found-message-not-found/316019/1 "2022-10-06T22:40:50Z")

</div>

Hello,

this is Michael from germany and i am reaching out to you because i have to finish my master thesis before 31.10.2022.

I had working code in july 2022 which i didn't touch since then. I used the online 2 weeks trial vom [elastic.co](http://elastic.co) to connect and do my stuff. Now i want to execute the code again on a new 2 weeks trial but i am facing an error, which i can't solve.  
What happened in the meanwhile:  
a) in july i used version 8.2.0 of the software while meanwhile Elasticsearch company released  
version 8.4.0 of their software.  
b) i changed password in the code, because i have a new 2 weeks trial now.

Here are some short example codes which all fail (actually my real code is bigger but these are small examples). Only the code after the line `// "productive code"` changes

Creating an index:

```auto
package Kapselung;

import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestClientBuilder.HttpClientConfigCallback;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
import co.elastic.clients.transport.ElasticsearchTransport;
import co.elastic.clients.transport.rest_client.RestClientTransport;

public class create_index {

	public static void main(String[] args) {
		String username = "elastic";
		String password = "JotkB5QY5v9IN0qRtvf6d5dL";
		String host = "gattinger-fourth.kb.us-central1.gcp.cloud.es.io";
		int port = 9243;
		RestClient restClient;
		ElasticsearchClient ESClient;

		// https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/connecting.html
		// https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/_basic_authentication.html
		final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
		credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
		HttpClientConfigCallback httpClientConfigCallback = new HttpClientConfigCallback() {
			@Override
			public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
				httpClientBuilder.disableAuthCaching();
				return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
			}
		};

		// Create the low-level client
		RestClientBuilder restClientBuilder = RestClient.builder(new HttpHost(host, port, "https"));
		restClientBuilder.setHttpClientConfigCallback(httpClientConfigCallback);
		restClient = restClientBuilder.build();

		// Create the transport with a Jackson mapper
		ElasticsearchTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());
		ESClient = new ElasticsearchClient(transport);

		// "productive code"
		try {
			ESClient.indices().create(c -> c.index("products100"));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}

```

Failure is:

```auto
co.elastic.clients.transport.TransportException: [es/indices.create] Failed to decode error response
	at co.elastic.clients.transport.rest_client.RestClientTransport.getHighLevelResponse(RestClientTransport.java:290)
	at co.elastic.clients.transport.rest_client.RestClientTransport.performRequest(RestClientTransport.java:147)
	at co.elastic.clients.elasticsearch.indices.ElasticsearchIndicesClient.create(ElasticsearchIndicesClient.java:266)
	at co.elastic.clients.elasticsearch.indices.ElasticsearchIndicesClient.create(ElasticsearchIndicesClient.java:282)
	at Kapselung.create_index.main(create_index.java:51)
Caused by: org.elasticsearch.client.ResponseException: method [PUT], host [https://gattinger-fourth.kb.us-central1.gcp.cloud.es.io:9243], URI [/products100], status line [HTTP/1.1 404 Not Found]

	... 5 more

```

Or posting a document:

```auto
package Kapselung;

import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestClientBuilder.HttpClientConfigCallback;

import com.fasterxml.jackson.databind.ObjectMapper;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
import co.elastic.clients.transport.ElasticsearchTransport;
import co.elastic.clients.transport.rest_client.RestClientTransport;

public class post_document {

	public static void main(String[] args) {
		String username = "elastic";
		String password = "JotkB5QY5v9IN0qRtvf6d5dL";
		String host = "gattinger-fourth.kb.us-central1.gcp.cloud.es.io";
		int port = 9243;
		RestClient restClient;
		ElasticsearchClient ESClient;

		// https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/connecting.html
		// https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/_basic_authentication.html
		final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
		credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
		HttpClientConfigCallback httpClientConfigCallback = new HttpClientConfigCallback() {
			@Override
			public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
				httpClientBuilder.disableAuthCaching();
				return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
			}
		};

		// Create the low-level client
		RestClientBuilder restClientBuilder = RestClient.builder(new HttpHost(host, port, "https"));
		restClientBuilder.setHttpClientConfigCallback(httpClientConfigCallback);
		restClient = restClientBuilder.build();

		// Create the transport with a Jackson mapper
		ElasticsearchTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());
		ESClient = new ElasticsearchClient(transport);

		// "productive code"
		try {
			Request request = new Request("POST", "/products100/_doc");
			String document = "{\"sku\": \"21847816\",\"name\": \"Rasierapparat\",\"price\": 23.99}";
			ObjectMapper mapper = new ObjectMapper(); // Jackson Json
			request.setJsonEntity(mapper.writeValueAsString(document));
			Response response = restClient.performRequest(request);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}

```

failure:

```auto
org.elasticsearch.client.ResponseException: method [POST], host [https://gattinger-fourth.kb.us-central1.gcp.cloud.es.io:9243], URI [/products100/_doc], status line [HTTP/1.1 404 Not Found]
{"statusCode":404,"error":"Not Found","message":"Not Found"}
	at org.elasticsearch.client.RestClient.convertResponse(RestClient.java:346)
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:312)
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:287)
	at Kapselung.post_document.main(post_document.java:59)

```

Or just checking the Elasticsearch version:

```auto
package Kapselung;

import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestClientBuilder.HttpClientConfigCallback;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
import co.elastic.clients.transport.ElasticsearchTransport;
import co.elastic.clients.transport.rest_client.RestClientTransport;

public class getESClient_info_version_number {

	public static void main(String[] args) {
		String username = "elastic";
		String password = "JotkB5QY5v9IN0qRtvf6d5dL";
		String host = "gattinger-fourth.kb.us-central1.gcp.cloud.es.io";
		int port = 9243;
		RestClient restClient;
		ElasticsearchClient ESClient;

		// https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/connecting.html
		// https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/_basic_authentication.html
		final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
		credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
		HttpClientConfigCallback httpClientConfigCallback = new HttpClientConfigCallback() {
			@Override
			public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
				httpClientBuilder.disableAuthCaching();
				return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
			}
		};

		// Create the low-level client
		RestClientBuilder restClientBuilder = RestClient.builder(new HttpHost(host, port, "https"));
		restClientBuilder.setHttpClientConfigCallback(httpClientConfigCallback);
		restClient = restClientBuilder.build();

		// Create the transport with a Jackson mapper
		ElasticsearchTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());
		ESClient = new ElasticsearchClient(transport);

		// "productive code"
		try {
			System.out.println(ESClient.info().version().number());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}

```

Failure:

```auto
co.elastic.clients.transport.TransportException: [es/info] Missing [X-Elastic-Product] header. Please check that you are connecting to an Elasticsearch instance, and that any networking filters are preserving that header.
	at co.elastic.clients.transport.rest_client.RestClientTransport.checkProductHeader(RestClientTransport.java:351)
	at co.elastic.clients.transport.rest_client.RestClientTransport.getHighLevelResponse(RestClientTransport.java:253)
	at co.elastic.clients.transport.rest_client.RestClientTransport.performRequest(RestClientTransport.java:147)
	at co.elastic.clients.elasticsearch.ElasticsearchClient.info(ElasticsearchClient.java:976)
	at Kapselung.getESClient_info_version_number.main(getESClient_info_version_number.java:51)
Caused by: org.elasticsearch.client.ResponseException: method [GET], host [https://gattinger-fourth.kb.us-central1.gcp.cloud.es.io:9243], URI [/], status line [HTTP/1.1 200 OK]

```

And this is my pom.xml:

```auto

```

 4.0.0 00003 00004 0.0.1-SNAPSHOT 

```
<dependency>
  <groupId>co.elastic.clients</groupId>
  <artifactId>elasticsearch-java</artifactId>
  <version>8.2.0</version>
</dependency>

```

```
<dependency>
  <groupId>com.fasterxml.jackson.core</groupId>
  <artifactId>jackson-databind</artifactId>
  <version>2.12.3</version>
</dependency>

<!-- benötigt falls ClassNotFoundException: jakarta.json.spi.JsonProvider
https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/installation.html -->
<dependency>
  <groupId>jakarta.json</groupId>
  <artifactId>jakarta.json-api</artifactId>
  <version>2.0.1</version>
</dependency>
<!-- -->

```

 ``` ``` Changing dependency from 8.2.0 to 8.4.0 didn't help.

So i don't know what actually to do. Do you?

Yes i know that i spread the password, it is intentional so somebody could help me by actually executing it. It is only a 2 weeks trial so i don't care about the logindata.

Thanks - Enomine

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [October 7, 2022, 1:59am UTC](https://discuss.elastic.co/t/elasticsearch-8-java-client-responseexception-status-line-http-1-1-404-not-found-statuscode-404-error-not-found-message-not-found/316019/2 "2022-10-07T01:59:58Z")

</div>

Hi @Michael_Gattinger Welcome to the community and thanks for trying Elastic Cloud

Your should try `curl` outside your java program...

You have a simple error you are pointing at kibana not elasticsearch...

`gattinger-fourth.kb.us-central1.gcp.cloud.es.io`  
`-----------------^^.. es not kb.....`

correct

`gattinger-fourth.es.us-central1.gcp.cloud.es.io`  
`-----------------^^.. es not kb.....`

```auto
$ curl -u elastic:JotkB5QY5v9IN0qRtvf6d5dL https://gattinger-fourth.es.us-central1.gcp.cloud.es.io
{
  "name" : "instance-0000000001",
  "cluster_name" : "b63255165d3f4cbb8263aa78cbfe9bff",
  "cluster_uuid" : "8UdrUU9zQvOkSbkfvhbhJg",
  "version" : {
    "number" : "8.4.3",
    "build_flavor" : "default",
    "build_type" : "docker",
    "build_hash" : "42f05b9372a9a4a470db3b52817899b99a76ee73",
    "build_date" : "2022-10-04T07:17:24.662462378Z",
    "build_snapshot" : false,
    "lucene_version" : "9.3.0",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}

```

 ![Screen Shot 2022-10-06 at 7.01.49 PM](https://us1.discourse-cdn.com/elastic/original/3X/e/0/e044c33ea8def5702ab927c42713c46bf4c50e60.png)

**Now change your password immediately 🙂**

 ![Screen Shot 2022-10-06 at 6.58.45 PM](https://us1.discourse-cdn.com/elastic/original/3X/4/8/483741731a0b11db583c16b49253c6346133c406.png)

---

<div class="post-metadata">

**Author:** ![Michael\_Gattinger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_gattinger/32/99690_2.png) [@Michael\_Gattinger](https://discuss.elastic.co/u/Michael_Gattinger)\
**Post date:** [October 7, 2022, 12:12pm UTC](https://discuss.elastic.co/t/elasticsearch-8-java-client-responseexception-status-line-http-1-1-404-not-found-statuscode-404-error-not-found-message-not-found/316019/3 "2022-10-07T12:12:18Z")

</div>

Hey thanks for your help. I see it was a layer 8 problem.

And here is the next layer 8 problem: I have no clue how to get there where you point me to.

 ![Screenshot 2022-10-07 135049](https://us1.discourse-cdn.com/elastic/original/3X/b/5/b56e4d6a12e38fa3de220d63cc0cd84f402615d4.png)

As you have "Elastic Team" by your name i think you work for them. Then i propose that you tell them that it is hard to navigate from the point where i am stuck to the point where you want me to change the passwort. In summer there was something like "prices" or similar in the icon top right and when i clicked on that i landed somewhere where i could manage my stack. But this link does not exist any more. Now i have no clue how to get there. And one more: "prices" is not very intuitive to click on to get to stack management.

Thanks - Enomine

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [October 7, 2022, 2:44pm UTC](https://discuss.elastic.co/t/elasticsearch-8-java-client-responseexception-status-line-http-1-1-404-not-found-statuscode-404-error-not-found-message-not-found/316019/4 "2022-10-07T14:44:11Z")

</div>

Log into the elastic cloud console

[cloud.elastic.co](http://cloud.elastic.co)

That is the management console where you can see your deployments.

---

<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:** [November 4, 2022, 2:44pm UTC](https://discuss.elastic.co/t/elasticsearch-8-java-client-responseexception-status-line-http-1-1-404-not-found-statuscode-404-error-not-found-message-not-found/316019/5 "2022-11-04T14:44:43Z")

</div>

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