# Java.lang.NoSuchMethodError: org.elasticsearch.client.IndicesAdminClient.prepareExists

**URL:** https://discuss.elastic.co/t/java-lang-nosuchmethoderror-org-elasticsearch-client-indicesadminclient-prepareexists/13889
**Category:** Elasticsearch
**Created:** [October 9, 2013, 7:07pm UTC](https://discuss.elastic.co/t/java-lang-nosuchmethoderror-org-elasticsearch-client-indicesadminclient-prepareexists/13889 "2013-10-09T19:07:40Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Dennis](https://avatars.discourse-cdn.com/v4/letter/d/e56c9b/32.png) [@Dennis](https://discuss.elastic.co/u/Dennis)
#### Post date: [October 9, 2013, 7:07pm UTC](https://discuss.elastic.co/t/java-lang-nosuchmethoderror-org-elasticsearch-client-indicesadminclient-prepareexists/13889/1 "2013-10-09T19:07:40Z")

</div>

I'm getting the following error:

java.lang.NoSuchMethodError: org.elasticsearch.client.IndicesAdminClient.  
prepareExists([Ljava/lang/String;)Lorg/elasticsearch/action/admin/indices/  
exists/IndicesExistsRequestBuilder;

The code producing this was originally writtenfor ESearch 19.6 and am no  
recompiling it for 90.5 version.

At this link: [grepcode.com](http://grepcode.com) search for that method in version 90.5[http://grepcode.com/file/repo1.maven.org/maven2/org.elasticsearch/elasticsearch/0.90.5/org/elasticsearch/client/IndicesAdminClient.java#IndicesAdminClient.prepareExists(java.lang.String[])](http://grepcode.com/file/repo1.maven.org/maven2/org.elasticsearch/elasticsearch/0.90.5/org/elasticsearch/client/IndicesAdminClient.java#IndicesAdminClient.prepareExists%28java.lang.String%5B%5D%29),  
it doesn't show that method.

How do I replace this code? (I am just getting up to speed on this project:  
It's my project, but I hired out the various parts, and we're getting ready  
to launch and upgrading all the software first).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)
#### Post date: [October 9, 2013, 7:17pm UTC](https://discuss.elastic.co/t/java-lang-nosuchmethoderror-org-elasticsearch-client-indicesadminclient-prepareexists/13889/2 "2013-10-09T19:17:07Z")

</div>

That method doesn't seem to have changed. I still see it:

[https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/client/IndicesAdminClient.java#L147](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/client/IndicesAdminClient.java#L147)

Can you post a code fragment in case something is being overlooked?

BTW, are you using an IDE? Code completion really helps when transitioning  
between libraries/APIs.

Cheers,

Ivan

On Wed, Oct 9, 2013 at 12:07 PM, Dennis [gearond@gmail.com](mailto:gearond@gmail.com) wrote:

> I'm getting the following error:
> 
> java.lang.NoSuchMethodError: org.elasticsearch.client.IndicesAdminClient.  
> prepareExists([Ljava/lang/String;)Lorg/elasticsearch/action/admin/indices/  
> exists/IndicesExistsRequestBuilder;
> 
> The code producing this was originally writtenfor ESearch 19.6 and am no  
> recompiling it for 90.5 version.
> 
> At this link: [grepcode.com](http://grepcode.com) search for that method in version 90.5[http://grepcode.com/file/repo1.maven.org/maven2/org.elasticsearch/elasticsearch/0.90.5/org/elasticsearch/client/IndicesAdminClient.java#IndicesAdminClient.prepareExists(java.lang.String[])](http://grepcode.com/file/repo1.maven.org/maven2/org.elasticsearch/elasticsearch/0.90.5/org/elasticsearch/client/IndicesAdminClient.java#IndicesAdminClient.prepareExists%28java.lang.String%5B%5D%29),  
> it doesn't show that method.
> 
> How do I replace this code? (I am just getting up to speed on this  
> project: It's my project, but I hired out the various parts, and we're  
> getting ready to launch and upgrading all the software first).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Dennis](https://avatars.discourse-cdn.com/v4/letter/d/e56c9b/32.png) [@Dennis](https://discuss.elastic.co/u/Dennis)
#### Post date: [October 9, 2013, 9:00pm UTC](https://discuss.elastic.co/t/java-lang-nosuchmethoderror-org-elasticsearch-client-indicesadminclient-prepareexists/13889/3 "2013-10-09T21:00:14Z")

</div>

The text scrap is below. The 'isExists()' code section was originally  
'exists()', but that _IS_ a valid change. It wouldn't compile even until  
that was changed. Now, at the point this is called, USUALLY, there is an  
index already created. The code is NOT creating an index, however. I don't  
THINK that the error I listed in the JUNIT test should say method does't  
exist if it fails! I'm still trying to figure out why the index is not  
being created.

(by the way, this is part of an 'osem[http://www.compass-project.org/docs/latest/reference/html/core-osem.html](http://www.compass-project.org/docs/latest/reference/html/core-osem.html)'  
project) It was working fine on Java 1.6, ESearch 19.6.

```
private void ensureIndex(Class<?> clazz) {
    if (indexNames.containsKey(clazz))
        return;

    client.getClient().admin().cluster().prepareHealth()
            .setWaitForYellowStatus().execute().actionGet();

    String name = getIndexName(clazz);

    if 

```

(!client.getClient().admin().indices().prepareExists(name).execute()  
.actionGet().isExists()) {

client.getClient().admin().indices().prepareCreate(name).execute()  
.actionGet();  
}

```
    Map<String, Object> src = toObjectType(name,
            toObjectType("properties", getMapping(clazz), null), null);

    client.getClient().admin().indices().preparePutMapping(name)
            .setType(name).setIndices(name).setSource(src).execute()
            .actionGet();

    indexNames.put(clazz, name);
}

```

On Wednesday, October 9, 2013 12:17:07 PM UTC-7, Ivan Brusic wrote:

> That method doesn't seem to have changed. I still see it:
> 
> [https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/client/IndicesAdminClient.java#L147](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/client/IndicesAdminClient.java#L147)
> 
> Can you post a code fragment in case something is being overlooked?
> 
> BTW, are you using an IDE? Code completion really helps when transitioning  
> between libraries/APIs.
> 
> Cheers,
> 
> Ivan
> 
> On Wed, Oct 9, 2013 at 12:07 PM, Dennis \<[gea...@gmail.com](mailto:gea...@gmail.com) \<javascript:\>\>wrote:
> 
> > I'm getting the following error:
> > 
> > java.lang.NoSuchMethodError: org.elasticsearch.client.IndicesAdminClient.  
> > prepareExists([Ljava/lang/String;)Lorg/elasticsearch/action/admin/indices  
> > /exists/IndicesExistsRequestBuilder;
> > 
> > The code producing this was originally writtenfor ESearch 19.6 and am no  
> > recompiling it for 90.5 version.
> > 
> > At this link: [grepcode.com](http://grepcode.com) search for that method in version 90.5[http://grepcode.com/file/repo1.maven.org/maven2/org.elasticsearch/elasticsearch/0.90.5/org/elasticsearch/client/IndicesAdminClient.java#IndicesAdminClient.prepareExists(java.lang.String[])](http://grepcode.com/file/repo1.maven.org/maven2/org.elasticsearch/elasticsearch/0.90.5/org/elasticsearch/client/IndicesAdminClient.java#IndicesAdminClient.prepareExists%28java.lang.String%5B%5D%29),  
> > it doesn't show that method.
> > 
> > How do I replace this code? (I am just getting up to speed on this  
> > project: It's my project, but I hired out the various parts, and we're  
> > getting ready to launch and upgrading all the software first).
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Dennis](https://avatars.discourse-cdn.com/v4/letter/d/e56c9b/32.png) [@Dennis](https://discuss.elastic.co/u/Dennis)
#### Post date: [October 9, 2013, 10:27pm UTC](https://discuss.elastic.co/t/java-lang-nosuchmethoderror-org-elasticsearch-client-indicesadminclient-prepareexists/13889/4 "2013-10-09T22:27:39Z")

</div>

Well, my partner is on the other end of the repo postings, and now the  
main listed here is gone. But we now get a new kind of error that seems  
harder to track down.

Unexpected exception,  
expected\<org.elasticsearch.indices.IndexMissingException\> but  
was\<org.elasticsearch.transport.TransportSerializationException\>

On Wednesday, October 9, 2013 2:00:14 PM UTC-7, Dennis wrote:

> The text scrap is below. The 'isExists()' code section was originally  
> 'exists()', but that _IS_ a valid change. It wouldn't compile even until  
> that was changed. Now, at the point this is called, USUALLY, there is an  
> index already created. The code is NOT creating an index, however. I don't  
> THINK that the error I listed in the JUNIT test should say method does't  
> exist if it fails! I'm still trying to figure out why the index is not  
> being created.
> 
> (by the way, this is part of an 'osem[http://www.compass-project.org/docs/latest/reference/html/core-osem.html](http://www.compass-project.org/docs/latest/reference/html/core-osem.html)'  
> project) It was working fine on Java 1.6, ESearch 19.6.
> 
> ```
> private void ensureIndex(Class<?> clazz) {
> if (indexNames.containsKey(clazz))
> return;
> 
> client.getClient().admin().cluster().prepareHealth()
> .setWaitForYellowStatus().execute().actionGet();
> 
> String name = getIndexName(clazz);
> 
> if 
> 
> ```
> 
> (!client.getClient().admin().indices().prepareExists(name).execute()  
> .actionGet().isExists()) {
> 
> client.getClient().admin().indices().prepareCreate(name).execute()  
> .actionGet();  
> }
> 
> ```
> Map<String, Object> src = toObjectType(name,
> toObjectType("properties", getMapping(clazz), null), null);
> 
> client.getClient().admin().indices().preparePutMapping(name)
> .setType(name).setIndices(name).setSource(src).execute()
> .actionGet();
> 
> indexNames.put(clazz, name);
> }
> 
> ```
> 
> On Wednesday, October 9, 2013 12:17:07 PM UTC-7, Ivan Brusic wrote:
> 
> > That method doesn't seem to have changed. I still see it:
> > 
> > [https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/client/IndicesAdminClient.java#L147](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/client/IndicesAdminClient.java#L147)
> > 
> > Can you post a code fragment in case something is being overlooked?
> > 
> > BTW, are you using an IDE? Code completion really helps when  
> > transitioning between libraries/APIs.
> > 
> > Cheers,
> > 
> > Ivan
> > 
> > On Wed, Oct 9, 2013 at 12:07 PM, Dennis [gea...@gmail.com](mailto:gea...@gmail.com) wrote:
> > 
> > > I'm getting the following error:
> > > 
> > > java.lang.NoSuchMethodError: org.elasticsearch.client.IndicesAdminClient  
> > > .prepareExists([Ljava/lang/String;)Lorg/elasticsearch/action/admin/  
> > > indices/exists/IndicesExistsRequestBuilder;
> > > 
> > > The code producing this was originally writtenfor ESearch 19.6 and am no  
> > > recompiling it for 90.5 version.
> > > 
> > > At this link: [grepcode.com](http://grepcode.com) search for that method in version 90.5[http://grepcode.com/file/repo1.maven.org/maven2/org.elasticsearch/elasticsearch/0.90.5/org/elasticsearch/client/IndicesAdminClient.java#IndicesAdminClient.prepareExists(java.lang.String[])](http://grepcode.com/file/repo1.maven.org/maven2/org.elasticsearch/elasticsearch/0.90.5/org/elasticsearch/client/IndicesAdminClient.java#IndicesAdminClient.prepareExists%28java.lang.String%5B%5D%29),  
> > > it doesn't show that method.
> > > 
> > > How do I replace this code? (I am just getting up to speed on this  
> > > project: It's my project, but I hired out the various parts, and we're  
> > > getting ready to launch and upgrading all the software first).
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Dennis](https://avatars.discourse-cdn.com/v4/letter/d/e56c9b/32.png) [@Dennis](https://discuss.elastic.co/u/Dennis)
#### Post date: [October 22, 2013, 11:52pm UTC](https://discuss.elastic.co/t/java-lang-nosuchmethoderror-org-elasticsearch-client-indicesadminclient-prepareexists/13889/5 "2013-10-22T23:52:30Z")

</div>

Turns out that ES has changed the method names of several methods in recent  
code to bring them all more in line with a naming convention. 'exists'  
became 'isExists' and 'sourcesAsMap' became 'getSourceAsMap'

Fixed these and some other niggly issues, and voila! It all works.

On Wednesday, October 9, 2013 3:27:39 PM UTC-7, Dennis wrote:

> Well, my partner is on the other end of the repo postings, and now the  
> main listed here is gone. But we now get a new kind of error that seems  
> harder to track down.
> 
> Unexpected exception,  
> expected\<org.elasticsearch.indices.IndexMissingException\> but  
> was\<org.elasticsearch.transport.TransportSerializationException\>
> 
> On Wednesday, October 9, 2013 2:00:14 PM UTC-7, Dennis wrote:
> 
> > The text scrap is below. The 'isExists()' code section was originally  
> > 'exists()', but that _IS_ a valid change. It wouldn't compile even until  
> > that was changed. Now, at the point this is called, USUALLY, there is an  
> > index already created. The code is NOT creating an index, however. I don't  
> > THINK that the error I listed in the JUNIT test should say method does't  
> > exist if it fails! I'm still trying to figure out why the index is not  
> > being created.
> > 
> > (by the way, this is part of an 'osem[http://www.compass-project.org/docs/latest/reference/html/core-osem.html](http://www.compass-project.org/docs/latest/reference/html/core-osem.html)'  
> > project) It was working fine on Java 1.6, ESearch 19.6.
> > 
> > ```
> > private void ensureIndex(Class<?> clazz) {
> > if (indexNames.containsKey(clazz))
> > return;
> > 
> > client.getClient().admin().cluster().prepareHealth()
> > .setWaitForYellowStatus().execute().actionGet();
> > 
> > String name = getIndexName(clazz);
> > 
> > if 
> > 
> > ```
> > 
> > (!client.getClient().admin().indices().prepareExists(name).execute()  
> > .actionGet().isExists()) {
> > 
> > client.getClient().admin().indices().prepareCreate(name).execute()  
> > .actionGet();  
> > }
> > 
> > ```
> > Map<String, Object> src = toObjectType(name,
> > toObjectType("properties", getMapping(clazz), null), 
> > 
> > ```
> > 
> > null);
> > 
> > ```
> > client.getClient().admin().indices().preparePutMapping(name)
> > .setType(name).setIndices(name).setSource(src).execute()
> > .actionGet();
> > 
> > indexNames.put(clazz, name);
> > }
> > 
> > ```
> > 
> > On Wednesday, October 9, 2013 12:17:07 PM UTC-7, Ivan Brusic wrote:
> > 
> > > That method doesn't seem to have changed. I still see it:
> > > 
> > > [https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/client/IndicesAdminClient.java#L147](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/client/IndicesAdminClient.java#L147)
> > > 
> > > Can you post a code fragment in case something is being overlooked?
> > > 
> > > BTW, are you using an IDE? Code completion really helps when  
> > > transitioning between libraries/APIs.
> > > 
> > > Cheers,
> > > 
> > > Ivan
> > > 
> > > On Wed, Oct 9, 2013 at 12:07 PM, Dennis [gea...@gmail.com](mailto:gea...@gmail.com) wrote:
> > > 
> > > > I'm getting the following error:
> > > > 
> > > > java.lang.NoSuchMethodError: org.elasticsearch.client.  
> > > > IndicesAdminClient.prepareExists([Ljava/lang/String;)Lorg/elasticsearch  
> > > > /action/admin/indices/exists/IndicesExistsRequestBuilder;
> > > > 
> > > > The code producing this was originally writtenfor ESearch 19.6 and am  
> > > > no recompiling it for 90.5 version.
> > > > 
> > > > At this link: [grepcode.com](http://grepcode.com) search for that method in version 90.5[http://grepcode.com/file/repo1.maven.org/maven2/org.elasticsearch/elasticsearch/0.90.5/org/elasticsearch/client/IndicesAdminClient.java#IndicesAdminClient.prepareExists(java.lang.String[])](http://grepcode.com/file/repo1.maven.org/maven2/org.elasticsearch/elasticsearch/0.90.5/org/elasticsearch/client/IndicesAdminClient.java#IndicesAdminClient.prepareExists%28java.lang.String%5B%5D%29),  
> > > > it doesn't show that method.
> > > > 
> > > > How do I replace this code? (I am just getting up to speed on this  
> > > > project: It's my project, but I hired out the various parts, and we're  
> > > > getting ready to launch and upgrading all the software first).
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to the Google  
> > > > Groups "elasticsearch" group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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: [July 6, 2017, 2:11am UTC](https://discuss.elastic.co/t/java-lang-nosuchmethoderror-org-elasticsearch-client-indicesadminclient-prepareexists/13889/6 "2017-07-06T02:11:06Z")

</div>


