# Embedded ElasticSearch On Java

**URL:** <https://discuss.elastic.co/t/embedded-elasticsearch-on-java/6032>\
**Category:** Elasticsearch\
**Created:** [November 30, 2011, 11:55pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java/6032 "2011-11-30T23:55:57Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![samCougars](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@samCougars](https://discuss.elastic.co/u/samCougars)\
**Post date:** [November 30, 2011, 11:55pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java/6032/1 "2011-11-30T23:55:57Z")

</div>

All

I have a webapp (JAVA) with a list of items on the page. All these  
items are generated on html with session variables. I want to use  
ElasticSearch on the back end to do a search for items with different  
search criteria. Is there a sample I can use it as a resource?

Thanks

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [December 1, 2011, 2:08pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java/6032/2 "2011-12-01T14:08:55Z")

</div>

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

On Thu, Dec 1, 2011 at 1:55 AM, Sam [sbaniya@gmail.com](mailto:sbaniya@gmail.com) wrote:

> All
> 
> I have a webapp (JAVA) with a list of items on the page. All these  
> items are generated on html with session variables. I want to use  
> Elasticsearch on the back end to do a search for items with different  
> search criteria. Is there a sample I can use it as a resource?
> 
> Thanks

---

<div class="post-metadata">

**Author:** ![samCougars](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@samCougars](https://discuss.elastic.co/u/samCougars)\
**Post date:** [December 1, 2011, 6:12pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java/6032/3 "2011-12-01T18:12:46Z")

</div>

Do you need to have a cluster setup to use elasticSearch? I'm thinking to feed on elasticSearch with JSON.  
I'm having an issue to create a node at the very beginning.  
Node node = NodeBuilder.nodeBuilder().node();  
And it throws an error as follows:  
java.lang.NoSuchMethodError: org.apache.log4j.Logger.isTraceEnabled()Z  
at org.elasticsearch.common.logging.log4j.Log4jESLogger.isTraceEnabled(Log4jESLogger.java:57)  
at org.elasticsearch.common.logging.support.AbstractESLogger.trace(AbstractESLogger.java:48)  
at org.elasticsearch.monitor.MonitorModule.configure(MonitorModule.java:86)  
at org.elasticsearch.common.inject.AbstractModule.configure(AbstractModule.java:59)  
at org.elasticsearch.common.inject.spi.Elements$RecordingBinder.install(Elements.java:210)  
at org.elasticsearch.common.inject.spi.Elements.getElements(Elements.java:91)  
at org.elasticsearch.common.inject.InjectorShell$Builder.build(InjectorShell.java:142)  
at org.elasticsearch.common.inject.InjectorBuilder.build(InjectorBuilder.java:103)  
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:93)  
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:70)  
at org.elasticsearch.common.inject.ModulesBuilder.createInjector(ModulesBuilder.java:58)  
at org.elasticsearch.node.internal.InternalNode.(InternalNode.java:148)  
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:159)  
at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:166)

Any suggestions?

---

<div class="post-metadata">

**Author:** ![Karussell1](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@Karussell1](https://discuss.elastic.co/u/Karussell1)\
**Post date:** [December 2, 2011, 9:04pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java/6032/4 "2011-12-02T21:04:29Z")

</div>

If you want to use ES on the backend you should start an ES via the  
normal installation procedure and connect to it from the webapp via  
the transport client.

If you want to start ES inside the webapp you can have a look into the  
wares plugin.

Peter.

On 1 Dez., 19:12, samCougars [sban...@gmail.com](mailto:sban...@gmail.com) wrote:

> Do you need to have a cluster setup to use elasticSearch? I'm thinking to  
> feed on elasticSearch with JSON.  
> I'm having an issue to create a node at the very beginning.  
> Node node = NodeBuilder.nodeBuilder().node();  
> And it throws an error as follows:  
> java.lang.NoSuchMethodError: org.apache.log4j.Logger.isTraceEnabled()Z  
> at  
> org.elasticsearch.common.logging.log4j.Log4jESLogger.isTraceEnabled(Log4jES Logger.java:57)  
> at  
> org.elasticsearch.common.logging.support.AbstractESLogger.trace(AbstractESL ogger.java:48)  
> at  
> org.elasticsearch.monitor.MonitorModule.configure(MonitorModule.java:86)  
> at  
> org.elasticsearch.common.inject.AbstractModule.configure(AbstractModule.jav a:59)  
> at  
> org.elasticsearch.common.inject.spi.Elements$RecordingBinder.install(Elemen ts.java:210)  
> at  
> org.elasticsearch.common.inject.spi.Elements.getElements(Elements.java:91)  
> at  
> org.elasticsearch.common.inject.InjectorShell$Builder.build(InjectorShell.j ava:142)  
> at  
> org.elasticsearch.common.inject.InjectorBuilder.build(InjectorBuilder.java: 103)  
> at  
> org.elasticsearch.common.inject.Guice.createInjector(Guice.java:93)  
> at  
> org.elasticsearch.common.inject.Guice.createInjector(Guice.java:70)  
> at  
> org.elasticsearch.common.inject.ModulesBuilder.createInjector(ModulesBuilde r.java:58)  
> at  
> org.elasticsearch.node.internal.InternalNode.(InternalNode.java:148)  
> at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:159)  
> at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:166)
> 
> Any suggestions?
> 
> --  
> View this message in context:[http://elasticsearch-users.115913.n3.nabble.com/Embedded-ElasticSearc](http://elasticsearch-users.115913.n3.nabble.com/Embedded-ElasticSearc)...  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![samCougars](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@samCougars](https://discuss.elastic.co/u/samCougars)\
**Post date:** [December 2, 2011, 9:28pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java/6032/5 "2011-12-02T21:28:40Z")

</div>

I was playing around w/ other references and finally I got the concept working. Here is a sample of my java code:  
String jsonString1 = "{" +  
""room":"livingroom","+  
""color":"red" "+  
"}";  
String jsonString2 = "{" +  
""room":"familyroom","+  
""color":"white" "+  
"}";  
String jsonString3 = "{" +  
""room":"kitchen","+  
""color":"blue" "+  
"}";

```
  String jsonString4 = "{" +
    "\"room\":\"bathroom\","+
    "\"color\":\"white\" "+
    "}";

  String jsonString5 = "{" +
    "\"room\":\"garage\","+
    "\"color\":\"blue\" "+
    "}";

  Node node = null;
  node = NodeBuilder.nodeBuilder().node();

  Client client = node.client();
  client.prepareIndex("house", "room", String.valueOf("1")).setSource(jsonString1).execute().actionGet();
  client.prepareIndex("house", "room", String.valueOf("2")).setSource(jsonString2).execute().actionGet();
  client.prepareIndex("house", "room", String.valueOf("3")).setSource(jsonString3).execute().actionGet();
  client.prepareIndex("house", "room", String.valueOf("4")).setSource(jsonString4).execute().actionGet();
  client.prepareIndex("house", "room", String.valueOf("5")).setSource(jsonString5).execute().actionGet();

  QueryBuilder queryBuilder = QueryBuilders.termQuery("color", "white");
  SearchRequestBuilder searchRequestBuilder = client.prepareSearch("house");
  searchRequestBuilder.setTypes("room");
  searchRequestBuilder.setSearchType(SearchType.DEFAULT);
  searchRequestBuilder.setQuery(queryBuilder);
  searchRequestBuilder.setFrom(0).setSize(60).setExplain(true);
  SearchResponse resp = searchRequestBuilder.execute().actionGet();
  for (SearchHit hit : resp.getHits())
    System.out.println("Hit ID: "+hit.getId());
  node.close();
}
catch (Exception e)
{
  e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}

```

Output of this hits :  
Hit ID: 4  
Hit ID: 2

---

<div class="post-metadata">

**Author:** ![feenz](https://avatars.discourse-cdn.com/v4/letter/f/4bbf92/32.png) [@feenz](https://discuss.elastic.co/u/feenz)\
**Post date:** [August 11, 2014, 4:44pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java/6032/6 "2014-08-11T16:44:53Z")

</div>

I continue to run into the same issue...

NoSuchMethodError: org.apache.log4j.Logger.isTraceEnable()z ...

I have included these in my pom:

elasticsearch-1.3.1.jar

slf4j-api-1.7.7.jar  
slf4j-ext-1.7.7.jar  
log4j-core-2.0-rc2.jar  
log4j-api-2.0-rc2.jar  
log4j-slf4j-impl-2.0-rc2.jar

How did you end up overcoming this problem???

---

<div class="post-metadata">

**Author:** ![feenz](https://avatars.discourse-cdn.com/v4/letter/f/4bbf92/32.png) [@feenz](https://discuss.elastic.co/u/feenz)\
**Post date:** [August 11, 2014, 4:56pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java/6032/7 "2014-08-11T16:56:29Z")

</div>

All,

I know this post is old, but I continue to have an issue with this...

I get an NoSuchMethodError: org.apache.log4j.Logger.isTraceEnabled()Z  
exception when I run

Node node = NodeBuilder.nodeBuilder().local(true).node(); // exception  
thrown here...  
Client client = node.client();

I have tried including several different slf4j and log4j libraries...

Right now I have defined in my pom.xml:

slf4j-api-1.7.7.jar  
slf4j-ext-1.7.7.jar  
log4j-core-2.0.jar  
log4j-api-2.0.jar

Any suggestions?  
log4j-slf4j-impl-2.0.jar

On Wednesday, November 30, 2011 6:55:57 PM UTC-5, Sam wrote:

> All
> 
> I have a webapp (JAVA) with a list of items on the page. All these  
> items are generated on html with session variables. I want to use  
> Elasticsearch on the back end to do a search for items with different  
> search criteria. Is there a sample I can use it as a resource?
> 
> Thanks

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/78975d76-1c5e-40b3-a4c7-c47f8bbb798b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/78975d76-1c5e-40b3-a4c7-c47f8bbb798b%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Vivek\_Sachdeva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vivek_sachdeva/32/1339_2.png) [@Vivek\_Sachdeva](https://discuss.elastic.co/u/Vivek_Sachdeva)\
**Post date:** [August 11, 2014, 5:19pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java/6032/8 "2014-08-11T17:19:06Z")

</div>

Have you tried using transport client for connecting...

On Monday, August 11, 2014 10:26:29 PM UTC+5:30, Kfeenz wrote:

> All,
> 
> I know this post is old, but I continue to have an issue with this...
> 
> I get an NoSuchMethodError: org.apache.log4j.Logger.isTraceEnabled()Z  
> exception when I run
> 
> Node node = NodeBuilder.nodeBuilder().local(true).node(); // exception  
> thrown here...  
> Client client = node.client();
> 
> I have tried including several different slf4j and log4j libraries...
> 
> Right now I have defined in my pom.xml:
> 
> slf4j-api-1.7.7.jar  
> slf4j-ext-1.7.7.jar  
> log4j-core-2.0.jar  
> log4j-api-2.0.jar
> 
> Any suggestions?  
> log4j-slf4j-impl-2.0.jar
> 
> On Wednesday, November 30, 2011 6:55:57 PM UTC-5, Sam wrote:
> 
> > All
> > 
> > I have a webapp (JAVA) with a list of items on the page. All these  
> > items are generated on html with session variables. I want to use  
> > Elasticsearch on the back end to do a search for items with different  
> > search criteria. Is there a sample I can use it as a resource?
> > 
> > Thanks

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/fde2361b-1a5f-4882-ab79-106a111f5242%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fde2361b-1a5f-4882-ab79-106a111f5242%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![feenz](https://avatars.discourse-cdn.com/v4/letter/f/4bbf92/32.png) [@feenz](https://discuss.elastic.co/u/feenz)\
**Post date:** [August 11, 2014, 6:04pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java/6032/9 "2014-08-11T18:04:43Z")

</div>

So I am very new to elasticsearch... so I apologize in advance..

I started a local instance of elasticsearch and I am trying to connect to  
it through the Java API.

I was under the impression that the transport client was for remote clients?

I tried:

@Test  
public void testIndexResponse() {

Client client = new TransportClient().setTransportAddress(new  
InetSocketTransportAddress("localhost", 9300));

String json = "{" +  
""user":"kimchy"," +  
""postDate":"2013-01-30"," +  
""message":"trying out Elasticsearch"" +  
"}";

IndexResponse response = client.prepareIndex("twitter", "tweet")  
.setSource(json)  
.execute()  
.actionGet();

client.close();

System.out.println(response.getIndex());  
}

I receive org.elasticsearch.client.transport.NoNodeAvailableException: None  
of the configured nodes are available: .

On Monday, August 11, 2014 1:19:06 PM UTC-4, Vivek Sachdeva wrote:

> Have you tried using transport client for connecting...
> 
> On Monday, August 11, 2014 10:26:29 PM UTC+5:30, Kfeenz wrote:
> 
> > All,
> > 
> > I know this post is old, but I continue to have an issue with this...
> > 
> > I get an NoSuchMethodError: org.apache.log4j.Logger.isTraceEnabled()Z  
> > exception when I run
> > 
> > Node node = NodeBuilder.nodeBuilder().local(true).node(); // exception  
> > thrown here...  
> > Client client = node.client();
> > 
> > I have tried including several different slf4j and log4j libraries...
> > 
> > Right now I have defined in my pom.xml:
> > 
> > slf4j-api-1.7.7.jar  
> > slf4j-ext-1.7.7.jar  
> > log4j-core-2.0.jar  
> > log4j-api-2.0.jar
> > 
> > Any suggestions?  
> > log4j-slf4j-impl-2.0.jar
> > 
> > On Wednesday, November 30, 2011 6:55:57 PM UTC-5, Sam wrote:
> > 
> > > All
> > > 
> > > I have a webapp (JAVA) with a list of items on the page. All these  
> > > items are generated on html with session variables. I want to use  
> > > Elasticsearch on the back end to do a search for items with different  
> > > search criteria. Is there a sample I can use it as a resource?
> > > 
> > > Thanks

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/f0b50999-be99-4e03-b3ca-e99eb8f9ad4b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f0b50999-be99-4e03-b3ca-e99eb8f9ad4b%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [August 11, 2014, 8:11pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java/6032/10 "2014-08-11T20:11:12Z")

</div>

1. Never use constructs like " ... = new TransportClient()..." This uses a  
new client per call which is very inefficient. Use a singleton per JVM  
instead. Do not forget to close the TransportClient thread pool when JVM  
shuts down with client.threadPool().close()

2. Use TransportClient settings, you must set the field "cluster.name" with  
the cluster name you want to connect to. Otherwise, you won't be able to  
connect to any node.

Jörg

On Mon, Aug 11, 2014 at 8:04 PM, Kfeenz [kfeeney5506@gmail.com](mailto:kfeeney5506@gmail.com) wrote:

> So I am very new to elasticsearch... so I apologize in advance..
> 
> I started a local instance of elasticsearch and I am trying to connect to  
> it through the Java API.
> 
> I was under the impression that the transport client was for remote  
> clients?
> 
> I tried:
> 
> @Test  
> public void testIndexResponse() {
> 
> Client client = new TransportClient().setTransportAddress(new  
> InetSocketTransportAddress("localhost", 9300));
> 
> String json = "{" +  
> ""user":"kimchy"," +  
> ""postDate":"2013-01-30"," +  
> ""message":"trying out Elasticsearch"" +  
> "}";
> 
> IndexResponse response = client.prepareIndex("twitter", "tweet")  
> .setSource(json)  
> .execute()  
> .actionGet();
> 
> client.close();
> 
> System.out.println(response.getIndex());  
> }
> 
> I receive org.elasticsearch.client.transport.NoNodeAvailableException:  
> None of the configured nodes are available: .
> 
> On Monday, August 11, 2014 1:19:06 PM UTC-4, Vivek Sachdeva wrote:
> 
> > Have you tried using transport client for connecting...
> > 
> > On Monday, August 11, 2014 10:26:29 PM UTC+5:30, Kfeenz wrote:
> > 
> > > All,
> > > 
> > > I know this post is old, but I continue to have an issue with this...
> > > 
> > > I get an NoSuchMethodError: org.apache.log4j.Logger.isTraceEnabled()Z  
> > > exception when I run
> > > 
> > > Node node = NodeBuilder.nodeBuilder().local(true).node(); // exception  
> > > thrown here...  
> > > Client client = node.client();
> > > 
> > > I have tried including several different slf4j and log4j libraries...
> > > 
> > > Right now I have defined in my pom.xml:
> > > 
> > > slf4j-api-1.7.7.jar  
> > > slf4j-ext-1.7.7.jar  
> > > log4j-core-2.0.jar  
> > > log4j-api-2.0.jar
> > > 
> > > Any suggestions?  
> > > log4j-slf4j-impl-2.0.jar
> > > 
> > > On Wednesday, November 30, 2011 6:55:57 PM UTC-5, Sam wrote:
> > > 
> > > > All
> > > > 
> > > > I have a webapp (JAVA) with a list of items on the page. All these  
> > > > items are generated on html with session variables. I want to use  
> > > > Elasticsearch on the back end to do a search for items with different  
> > > > search criteria. Is there a sample I can use it as a resource?
> > > > 
> > > > Thanks
> > > > 
> > > > --  
> > > > 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).  
> > > > To view this discussion on the web visit  
> > > > [https://groups.google.com/d/msgid/elasticsearch/f0b50999-be99-4e03-b3ca-e99eb8f9ad4b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f0b50999-be99-4e03-b3ca-e99eb8f9ad4b%40googlegroups.com)  
> > > > [https://groups.google.com/d/msgid/elasticsearch/f0b50999-be99-4e03-b3ca-e99eb8f9ad4b%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/f0b50999-be99-4e03-b3ca-e99eb8f9ad4b%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoH6EqTfLw3ACrbTi9twWw1ojegfo7UtydVp3dfR1dDfvg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoH6EqTfLw3ACrbTi9twWw1ojegfo7UtydVp3dfR1dDfvg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Vivek\_Sachdeva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vivek_sachdeva/32/1339_2.png) [@Vivek\_Sachdeva](https://discuss.elastic.co/u/Vivek_Sachdeva)\
**Post date:** [August 12, 2014, 9:45am UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java/6032/11 "2014-08-12T09:45:16Z")

</div>

Replace

.setTransportAddress(new InetSocketTransportAddress("localhost", 9300));

with

.addTransportAddress(new InetSocketTransportAddress('localhost', 9300)).

And I guess if you dont give cluster name, it automatically joins the  
default cluster.

I tried the code that you provided and changed above mentioned code. It  
works on my end. Can you try it?

On Monday, August 11, 2014 11:34:43 PM UTC+5:30, Kfeenz wrote:

> So I am very new to elasticsearch... so I apologize in advance..
> 
> I started a local instance of elasticsearch and I am trying to connect to  
> it through the Java API.
> 
> I was under the impression that the transport client was for remote  
> clients?
> 
> I tried:
> 
> @Test  
> public void testIndexResponse() {
> 
> Client client = new TransportClient().setTransportAddress(new  
> InetSocketTransportAddress("localhost", 9300));
> 
> String json = "{" +  
> ""user":"kimchy"," +  
> ""postDate":"2013-01-30"," +  
> ""message":"trying out Elasticsearch"" +  
> "}";
> 
> IndexResponse response = client.prepareIndex("twitter", "tweet")  
> .setSource(json)  
> .execute()  
> .actionGet();
> 
> client.close();
> 
> System.out.println(response.getIndex());  
> }
> 
> I receive org.elasticsearch.client.transport.NoNodeAvailableException:  
> None of the configured nodes are available: .
> 
> On Monday, August 11, 2014 1:19:06 PM UTC-4, Vivek Sachdeva wrote:
> 
> > Have you tried using transport client for connecting...
> > 
> > On Monday, August 11, 2014 10:26:29 PM UTC+5:30, Kfeenz wrote:
> > 
> > > All,
> > > 
> > > I know this post is old, but I continue to have an issue with this...
> > > 
> > > I get an NoSuchMethodError: org.apache.log4j.Logger.isTraceEnabled()Z  
> > > exception when I run
> > > 
> > > Node node = NodeBuilder.nodeBuilder().local(true).node(); // exception  
> > > thrown here...  
> > > Client client = node.client();
> > > 
> > > I have tried including several different slf4j and log4j libraries...
> > > 
> > > Right now I have defined in my pom.xml:
> > > 
> > > slf4j-api-1.7.7.jar  
> > > slf4j-ext-1.7.7.jar  
> > > log4j-core-2.0.jar  
> > > log4j-api-2.0.jar
> > > 
> > > Any suggestions?  
> > > log4j-slf4j-impl-2.0.jar
> > > 
> > > On Wednesday, November 30, 2011 6:55:57 PM UTC-5, Sam wrote:
> > > 
> > > > All
> > > > 
> > > > I have a webapp (JAVA) with a list of items on the page. All these  
> > > > items are generated on html with session variables. I want to use  
> > > > Elasticsearch on the back end to do a search for items with different  
> > > > search criteria. Is there a sample I can use it as a resource?
> > > > 
> > > > Thanks

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/cc92ae76-4d7f-4ef3-8a29-1df4755ca3d0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/cc92ae76-4d7f-4ef3-8a29-1df4755ca3d0%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![feenz](https://avatars.discourse-cdn.com/v4/letter/f/4bbf92/32.png) [@feenz](https://discuss.elastic.co/u/feenz)\
**Post date:** [August 12, 2014, 2:17pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java/6032/12 "2014-08-12T14:17:45Z")

</div>

@Jorg,

Thanks for the advice, I will make sure that I do so during actual  
implementation, but this is purely for testing the connection.. Also, I see  
a client.close() and a client.threadPool().shutdown(), but I do not see a  
client.threadPool().close(). I am using ES v1.3.1.

@ Vivek,

I am not sure how you were able to use 'localhost' vise "localhost". Java  
complains about an invalid character constant because 'localhost' is not a  
character but a String...

My current code is as follows... with still no luck...

Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name",  
"mycluster").build();

Client client = new TransportClient(settings).addTransportAddress(new  
InetSocketTransportAddress("localhost", 9300));

ClusterStatsRequestBuilder builder =  
client.admin().cluster().prepareClusterStats();

ClusterStatsResponse response = builder.execute().actionGet(); // fails on  
execute... NoNodeAvailableException

assertEquals("mycluster", response.getClusterName()); // never gets to this  
point

NoNodeAvailableException: None of the configured nodes are available

If I add a setting to the settings object

```
.put("client.transport.sniff", true);

```

I get a different error - [org.elasticsearch.client.transport] [Argus]  
failed to get local cluster state info for [#transport#-1]...

I can query the cluster using  
_[http://localhost:9200/\_cluster/health?pretty=true](http://localhost:9200/_cluster/health?pretty=true)_ which returns

{  
"cluster\_name" : "mycluster",  
"status" : "green",  
"timed\_out" : false,  
"number\_of\_nodes" : 1,  
"number\_of\_data\_nodes" : 1,  
"active\_primary\_shards" : 0,  
"active\_shards" : 0,  
"relocating\_shards" : 0,  
"initializing\_shards" : 0,  
"unassigned\_shards" : 0  
}

I am on Windows 7 64-bit.  
I am using Java 1.7\_u55.  
I am using ES version 1.3.1.  
I have included in my pom.xml:

- elasticsearch-1.3.1.jar
- lucene-core-4.9.0.jar

Any other suggestions are greatly appreciated.

On Tuesday, August 12, 2014 5:45:16 AM UTC-4, Vivek Sachdeva wrote:

> Replace
> 
> .setTransportAddress(new InetSocketTransportAddress("localhost", 9300));
> 
> with
> 
> .addTransportAddress(new InetSocketTransportAddress('localhost', 9300)).
> 
> And I guess if you dont give cluster name, it automatically joins the  
> default cluster.
> 
> I tried the code that you provided and changed above mentioned code. It  
> works on my end. Can you try it?
> 
> On Monday, August 11, 2014 11:34:43 PM UTC+5:30, Kfeenz wrote:
> 
> > So I am very new to elasticsearch... so I apologize in advance..
> > 
> > I started a local instance of elasticsearch and I am trying to connect to  
> > it through the Java API.
> > 
> > I was under the impression that the transport client was for remote  
> > clients?
> > 
> > I tried:
> > 
> > @Test  
> > public void testIndexResponse() {
> > 
> > Client client = new TransportClient().setTransportAddress(new  
> > InetSocketTransportAddress("localhost", 9300));
> > 
> > String json = "{" +  
> > ""user":"kimchy"," +  
> > ""postDate":"2013-01-30"," +  
> > ""message":"trying out Elasticsearch"" +  
> > "}";
> > 
> > IndexResponse response = client.prepareIndex("twitter", "tweet")  
> > .setSource(json)  
> > .execute()  
> > .actionGet();
> > 
> > client.close();
> > 
> > System.out.println(response.getIndex());  
> > }
> > 
> > I receive org.elasticsearch.client.transport.NoNodeAvailableException:  
> > None of the configured nodes are available: .
> > 
> > On Monday, August 11, 2014 1:19:06 PM UTC-4, Vivek Sachdeva wrote:
> > 
> > > Have you tried using transport client for connecting...
> > > 
> > > On Monday, August 11, 2014 10:26:29 PM UTC+5:30, Kfeenz wrote:
> > > 
> > > > All,
> > > > 
> > > > I know this post is old, but I continue to have an issue with this...
> > > > 
> > > > I get an NoSuchMethodError: org.apache.log4j.Logger.isTraceEnabled()Z  
> > > > exception when I run
> > > > 
> > > > Node node = NodeBuilder.nodeBuilder().local(true).node(); // exception  
> > > > thrown here...  
> > > > Client client = node.client();
> > > > 
> > > > I have tried including several different slf4j and log4j libraries...
> > > > 
> > > > Right now I have defined in my pom.xml:
> > > > 
> > > > slf4j-api-1.7.7.jar  
> > > > slf4j-ext-1.7.7.jar  
> > > > log4j-core-2.0.jar  
> > > > log4j-api-2.0.jar
> > > > 
> > > > Any suggestions?  
> > > > log4j-slf4j-impl-2.0.jar
> > > > 
> > > > On Wednesday, November 30, 2011 6:55:57 PM UTC-5, Sam wrote:
> > > > 
> > > > > All
> > > > > 
> > > > > I have a webapp (JAVA) with a list of items on the page. All these  
> > > > > items are generated on html with session variables. I want to use  
> > > > > Elasticsearch on the back end to do a search for items with different  
> > > > > search criteria. Is there a sample I can use it as a resource?
> > > > > 
> > > > > Thanks

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Vivek\_Sachdeva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vivek_sachdeva/32/1339_2.png) [@Vivek\_Sachdeva](https://discuss.elastic.co/u/Vivek_Sachdeva)\
**Post date:** [August 12, 2014, 2:29pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java/6032/13 "2014-08-12T14:29:23Z")

</div>

Actually I am using groovy... So 'localhost' and "localhost" are same fr  
me... Are you getting object of transport client in your code...

On Tuesday, August 12, 2014, Kfeenz [kfeeney5506@gmail.com](mailto:kfeeney5506@gmail.com) wrote:

> @Jorg,
> 
> Thanks for the advice, I will make sure that I do so during actual  
> implementation, but this is purely for testing the connection.. Also, I see  
> a client.close() and a client.threadPool().shutdown(), but I do not see a  
> client.threadPool().close(). I am using ES v1.3.1.
> 
> @ Vivek,
> 
> I am not sure how you were able to use 'localhost' vise "localhost". Java  
> complains about an invalid character constant because 'localhost' is not a  
> character but a String...
> 
> My current code is as follows... with still no luck...
> 
> Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name",  
> "mycluster").build();
> 
> Client client = new TransportClient(settings).addTransportAddress(new  
> InetSocketTransportAddress("localhost", 9300));
> 
> ClusterStatsRequestBuilder builder =  
> client.admin().cluster().prepareClusterStats();
> 
> ClusterStatsResponse response = builder.execute().actionGet(); // fails on  
> execute... NoNodeAvailableException
> 
> assertEquals("mycluster", response.getClusterName()); // never gets to  
> this point
> 
> NoNodeAvailableException: None of the configured nodes are available
> 
> If I add a setting to the settings object
> 
> ```
> .put("client.transport.sniff", true);
> 
> ```
> 
> I get a different error - [org.elasticsearch.client.transport] [Argus]  
> failed to get local cluster state info for [#transport#-1]...
> 
> I can query the cluster using _[http://localhost:9200/\_cluster/health?pretty=true](http://localhost:9200/_cluster/health?pretty=true)  
> [http://localhost:9200/\_cluster/health?pretty=true](http://localhost:9200/_cluster/health?pretty=true)_ which returns
> 
> {  
> "cluster\_name" : "mycluster",  
> "status" : "green",  
> "timed\_out" : false,  
> "number\_of\_nodes" : 1,  
> "number\_of\_data\_nodes" : 1,  
> "active\_primary\_shards" : 0,  
> "active\_shards" : 0,  
> "relocating\_shards" : 0,  
> "initializing\_shards" : 0,  
> "unassigned\_shards" : 0  
> }
> 
> I am on Windows 7 64-bit.  
> I am using Java 1.7\_u55.  
> I am using ES version 1.3.1.  
> I have included in my pom.xml:
> 
> - elasticsearch-1.3.1.jar
> - lucene-core-4.9.0.jar
> 
> Any other suggestions are greatly appreciated.
> 
> On Tuesday, August 12, 2014 5:45:16 AM UTC-4, Vivek Sachdeva wrote:
> 
> > Replace
> > 
> > .setTransportAddress(new InetSocketTransportAddress("localhost", 9300));
> > 
> > with
> > 
> > .addTransportAddress(new InetSocketTransportAddress('localhost', 9300)).
> > 
> > And I guess if you dont give cluster name, it automatically joins the  
> > default cluster.
> > 
> > I tried the code that you provided and changed above mentioned code. It  
> > works on my end. Can you try it?
> > 
> > On Monday, August 11, 2014 11:34:43 PM UTC+5:30, Kfeenz wrote:
> > 
> > > So I am very new to elasticsearch... so I apologize in advance..
> > > 
> > > I started a local instance of elasticsearch and I am trying to connect  
> > > to it through the Java API.
> > > 
> > > I was under the impression that the transport client was for remote  
> > > clients?
> > > 
> > > I tried:
> > > 
> > > @Test  
> > > public void testIndexResponse() {
> > > 
> > > Client client = new TransportClient().setTransportAddress(new  
> > > InetSocketTransportAddress("localhost", 9300));
> > > 
> > > String json = "{" +  
> > > ""user":"kimchy"," +  
> > > ""postDate":"2013-01-30"," +  
> > > ""message":"trying out Elasticsearch"" +  
> > > "}";
> > > 
> > > IndexResponse response = client.prepareIndex("twitter", "tweet")  
> > > .setSource(json)  
> > > .execute()  
> > > .actionGet();
> > > 
> > > client.close();
> > > 
> > > System.out.println(response.getIndex());  
> > > }
> > > 
> > > I receive org.elasticsearch.client.transport.NoNodeAvailableException:  
> > > None of the configured nodes are available: .
> > > 
> > > On Monday, August 11, 2014 1:19:06 PM UTC-4, Vivek Sachdeva wrote:
> > > 
> > > > Have you tried using transport client for connecting...
> > > > 
> > > > On Monday, August 11, 2014 10:26:29 PM UTC+5:30, Kfeenz wrote:
> > > > 
> > > > > All,
> > > > > 
> > > > > I know this post is old, but I continue to have an issue with this...
> > > > > 
> > > > > I get an NoSuchMethodError: org.apache.log4j.Logger.isTraceEnabled()Z  
> > > > > exception when I run
> > > > > 
> > > > > Node node = NodeBuilder.nodeBuilder().local(true).node(); //  
> > > > > exception thrown here...  
> > > > > Client client = node.client();
> > > > > 
> > > > > I have tried including several different slf4j and log4j libraries...
> > > > > 
> > > > > Right now I have defined in my pom.xml:
> > > > > 
> > > > > slf4j-api-1.7.7.jar  
> > > > > slf4j-ext-1.7.7.jar  
> > > > > log4j-core-2.0.jar  
> > > > > log4j-api-2.0.jar
> > > > > 
> > > > > Any suggestions?  
> > > > > log4j-slf4j-impl-2.0.jar
> > > > > 
> > > > > On Wednesday, November 30, 2011 6:55:57 PM UTC-5, Sam wrote:
> > > > > 
> > > > > > All
> > > > > > 
> > > > > > I have a webapp (JAVA) with a list of items on the page. All these  
> > > > > > items are generated on html with session variables. I want to use  
> > > > > > Elasticsearch on the back end to do a search for items with different  
> > > > > > search criteria. Is there a sample I can use it as a resource?
> > > > > > 
> > > > > > Thanks
> > > > > > 
> > > > > > --  
> > > > > > You received this message because you are subscribed to a topic in the  
> > > > > > Google Groups "elasticsearch" group.  
> > > > > > To unsubscribe from this topic, visit  
> > > > > > [https://groups.google.com/d/topic/elasticsearch/hl0P0NpCteQ/unsubscribe](https://groups.google.com/d/topic/elasticsearch/hl0P0NpCteQ/unsubscribe).  
> > > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com)  
> > > > > > \<javascript:\_e(%7B%7D,'cvml','elasticsearch%2Bunsubscribe@googlegroups.com');\>  
> > > > > > .  
> > > > > > To view this discussion on the web visit  
> > > > > > [https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com)  
> > > > > > [https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > > .  
> > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Thanks & Regards.  
Vivek Sachdeva  
Intelligrape Software Pvt. Ltd.

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CABpbMD2pY7%2B1YwRkR1d%2BKgv%3DEDU9vNuwaVGf0xL5xBA8aG27Qg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CABpbMD2pY7%2B1YwRkR1d%2BKgv%3DEDU9vNuwaVGf0xL5xBA8aG27Qg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![feenz](https://avatars.discourse-cdn.com/v4/letter/f/4bbf92/32.png) [@feenz](https://discuss.elastic.co/u/feenz)\
**Post date:** [August 12, 2014, 2:44pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java/6032/14 "2014-08-12T14:44:58Z")

</div>

Yes I receive back a TransportClient back from the call client = new  
TransportClient()

In debug I see that the nodeService.clusterName.value = "mycluster" as  
expected.

But it still fails on the execute() call

On Tuesday, August 12, 2014 10:29:30 AM UTC-4, Vivek Sachdeva wrote:

> Actually I am using groovy... So 'localhost' and "localhost" are same fr  
> me... Are you getting object of transport client in your code...
> 
> On Tuesday, August 12, 2014, Kfeenz \<[kfeen...@gmail.com](mailto:kfeen...@gmail.com) \<javascript:\>\>  
> wrote:
> 
> > @Jorg,
> > 
> > Thanks for the advice, I will make sure that I do so during actual  
> > implementation, but this is purely for testing the connection.. Also, I see  
> > a client.close() and a client.threadPool().shutdown(), but I do not see a  
> > client.threadPool().close(). I am using ES v1.3.1.
> > 
> > @ Vivek,
> > 
> > I am not sure how you were able to use 'localhost' vise "localhost". Java  
> > complains about an invalid character constant because 'localhost' is not a  
> > character but a String...
> > 
> > My current code is as follows... with still no luck...
> > 
> > Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name",  
> > "mycluster").build();
> > 
> > Client client = new TransportClient(settings).addTransportAddress(new  
> > InetSocketTransportAddress("localhost", 9300));
> > 
> > ClusterStatsRequestBuilder builder =  
> > client.admin().cluster().prepareClusterStats();
> > 
> > ClusterStatsResponse response = builder.execute().actionGet(); // fails  
> > on execute... NoNodeAvailableException
> > 
> > assertEquals("mycluster", response.getClusterName()); // never gets to  
> > this point
> > 
> > NoNodeAvailableException: None of the configured nodes are available
> > 
> > If I add a setting to the settings object
> > 
> > ```
> > .put("client.transport.sniff", true);
> > 
> > ```
> > 
> > I get a different error - [org.elasticsearch.client.transport] [Argus]  
> > failed to get local cluster state info for [#transport#-1]...
> > 
> > I can query the cluster using _[http://localhost:9200/\_cluster/health?pretty=true](http://localhost:9200/_cluster/health?pretty=true)  
> > [http://localhost:9200/\_cluster/health?pretty=true](http://localhost:9200/_cluster/health?pretty=true)_ which returns
> > 
> > {  
> > "cluster\_name" : "mycluster",  
> > "status" : "green",  
> > "timed\_out" : false,  
> > "number\_of\_nodes" : 1,  
> > "number\_of\_data\_nodes" : 1,  
> > "active\_primary\_shards" : 0,  
> > "active\_shards" : 0,  
> > "relocating\_shards" : 0,  
> > "initializing\_shards" : 0,  
> > "unassigned\_shards" : 0  
> > }
> > 
> > I am on Windows 7 64-bit.  
> > I am using Java 1.7\_u55.  
> > I am using ES version 1.3.1.  
> > I have included in my pom.xml:
> > 
> > - elasticsearch-1.3.1.jar
> > - lucene-core-4.9.0.jar
> > 
> > Any other suggestions are greatly appreciated.
> > 
> > On Tuesday, August 12, 2014 5:45:16 AM UTC-4, Vivek Sachdeva wrote:
> > 
> > > Replace
> > > 
> > > .setTransportAddress(new InetSocketTransportAddress("localhost",  
> > > 9300));
> > > 
> > > with
> > > 
> > > .addTransportAddress(new InetSocketTransportAddress('localhost', 9300)).
> > > 
> > > And I guess if you dont give cluster name, it automatically joins the  
> > > default cluster.
> > > 
> > > I tried the code that you provided and changed above mentioned code. It  
> > > works on my end. Can you try it?
> > > 
> > > On Monday, August 11, 2014 11:34:43 PM UTC+5:30, Kfeenz wrote:
> > > 
> > > > So I am very new to elasticsearch... so I apologize in advance..
> > > > 
> > > > I started a local instance of elasticsearch and I am trying to connect  
> > > > to it through the Java API.
> > > > 
> > > > I was under the impression that the transport client was for remote  
> > > > clients?
> > > > 
> > > > I tried:
> > > > 
> > > > @Test  
> > > > public void testIndexResponse() {
> > > > 
> > > > Client client = new TransportClient().setTransportAddress(new  
> > > > InetSocketTransportAddress("localhost", 9300));
> > > > 
> > > > String json = "{" +  
> > > > ""user":"kimchy"," +
> > > > 
> > > > ```
> > > > "\"postDate\":\"2013-01-30\"," +
> > > > "\"message\":\"trying out Elasticsearch\"" +
> > > > 
> > > > "}";
> > > > 
> > > > ```
> > > > 
> > > > IndexResponse response = client.prepareIndex("twitter", "tweet")
> > > > 
> > > > ```
> > > > .setSource(json)
> > > > .execute()
> > > > .actionGet();
> > > > 
> > > > ```
> > > > 
> > > > client.close();
> > > > 
> > > > System.out.println(response.getIndex());  
> > > > }
> > > > 
> > > > I receive org.elasticsearch.client.transport.NoNodeAvailableException:  
> > > > None of the configured nodes are available: .
> > > > 
> > > > On Monday, August 11, 2014 1:19:06 PM UTC-4, Vivek Sachdeva wrote:
> > > > 
> > > > > Have you tried using transport client for connecting...
> > > > > 
> > > > > On Monday, August 11, 2014 10:26:29 PM UTC+5:30, Kfeenz wrote:
> > > > > 
> > > > > > All,
> > > > > > 
> > > > > > I know this post is old, but I continue to have an issue with this...
> > > > > > 
> > > > > > I get an NoSuchMethodError: org.apache.log4j.Logger.isTraceEnabled()Z  
> > > > > > exception when I run
> > > > > > 
> > > > > > Node node = NodeBuilder.nodeBuilder().local(true).node(); //  
> > > > > > exception thrown here...  
> > > > > > Client client = node.client();
> > > > > > 
> > > > > > I have tried including several different slf4j and log4j libraries...
> > > > > > 
> > > > > > Right now I have defined in my pom.xml:
> > > > > > 
> > > > > > slf4j-api-1.7.7.jar  
> > > > > > slf4j-ext-1.7.7.jar  
> > > > > > log4j-core-2.0.jar  
> > > > > > log4j-api-2.0.jar
> > > > > > 
> > > > > > Any suggestions?  
> > > > > > log4j-slf4j-impl-2.0.jar
> > > > > > 
> > > > > > On Wednesday, November 30, 2011 6:55:57 PM UTC-5, Sam wrote:
> > > > > > 
> > > > > > > All
> > > > > > > 
> > > > > > > I have a webapp (JAVA) with a list of items on the page. All these  
> > > > > > > items are generated on html with session variables. I want to use  
> > > > > > > Elasticsearch on the back end to do a search for items with different  
> > > > > > > search criteria. Is there a sample I can use it as a resource?
> > > > > > > 
> > > > > > > Thanks
> > > > > > > 
> > > > > > > --  
> > > > > > > You received this message because you are subscribed to a topic in the  
> > > > > > > Google Groups "elasticsearch" group.  
> > > > > > > To unsubscribe from this topic, visit  
> > > > > > > [https://groups.google.com/d/topic/elasticsearch/hl0P0NpCteQ/unsubscribe](https://groups.google.com/d/topic/elasticsearch/hl0P0NpCteQ/unsubscribe).  
> > > > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > > To view this discussion on the web visit  
> > > > > > > [https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com)  
> > > > > > > [https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > > > .  
> > > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> Thanks & Regards.  
> Vivek Sachdeva  
> Intelligrape Software Pvt. Ltd.

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/f8df74fe-dc07-4421-892f-e2417ba56387%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f8df74fe-dc07-4421-892f-e2417ba56387%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [August 12, 2014, 2:52pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java/6032/15 "2014-08-12T14:52:57Z")

</div>

Yes, it's client.threadPool().shutdown().

Jörg

On Tue, Aug 12, 2014 at 4:17 PM, Kfeenz [kfeeney5506@gmail.com](mailto:kfeeney5506@gmail.com) wrote:

> @Jorg,
> 
> Thanks for the advice, I will make sure that I do so during actual  
> implementation, but this is purely for testing the connection.. Also, I see  
> a client.close() and a client.threadPool().shutdown(), but I do not see a  
> client.threadPool().close(). I am using ES v1.3.1.
> 
> @ Vivek,
> 
> I am not sure how you were able to use 'localhost' vise "localhost". Java  
> complains about an invalid character constant because 'localhost' is not a  
> character but a String...
> 
> My current code is as follows... with still no luck...
> 
> Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name",  
> "mycluster").build();
> 
> Client client = new TransportClient(settings).addTransportAddress(new  
> InetSocketTransportAddress("localhost", 9300));
> 
> ClusterStatsRequestBuilder builder =  
> client.admin().cluster().prepareClusterStats();
> 
> ClusterStatsResponse response = builder.execute().actionGet(); // fails on  
> execute... NoNodeAvailableException
> 
> assertEquals("mycluster", response.getClusterName()); // never gets to  
> this point
> 
> NoNodeAvailableException: None of the configured nodes are available
> 
> If I add a setting to the settings object
> 
> ```
> .put("client.transport.sniff", true);
> 
> ```
> 
> I get a different error - [org.elasticsearch.client.transport] [Argus]  
> failed to get local cluster state info for [#transport#-1]...
> 
> I can query the cluster using _[http://localhost:9200/\_cluster/health?pretty=true](http://localhost:9200/_cluster/health?pretty=true)  
> [http://localhost:9200/\_cluster/health?pretty=true](http://localhost:9200/_cluster/health?pretty=true)_ which returns
> 
> {  
> "cluster\_name" : "mycluster",  
> "status" : "green",  
> "timed\_out" : false,  
> "number\_of\_nodes" : 1,  
> "number\_of\_data\_nodes" : 1,  
> "active\_primary\_shards" : 0,  
> "active\_shards" : 0,  
> "relocating\_shards" : 0,  
> "initializing\_shards" : 0,  
> "unassigned\_shards" : 0  
> }
> 
> I am on Windows 7 64-bit.  
> I am using Java 1.7\_u55.  
> I am using ES version 1.3.1.  
> I have included in my pom.xml:
> 
> - elasticsearch-1.3.1.jar
> - lucene-core-4.9.0.jar
> 
> Any other suggestions are greatly appreciated.
> 
> On Tuesday, August 12, 2014 5:45:16 AM UTC-4, Vivek Sachdeva wrote:
> 
> > Replace
> > 
> > .setTransportAddress(new InetSocketTransportAddress("localhost", 9300));
> > 
> > with
> > 
> > .addTransportAddress(new InetSocketTransportAddress('localhost', 9300)).
> > 
> > And I guess if you dont give cluster name, it automatically joins the  
> > default cluster.
> > 
> > I tried the code that you provided and changed above mentioned code. It  
> > works on my end. Can you try it?
> > 
> > On Monday, August 11, 2014 11:34:43 PM UTC+5:30, Kfeenz wrote:
> > 
> > > So I am very new to elasticsearch... so I apologize in advance..
> > > 
> > > I started a local instance of elasticsearch and I am trying to connect  
> > > to it through the Java API.
> > > 
> > > I was under the impression that the transport client was for remote  
> > > clients?
> > > 
> > > I tried:
> > > 
> > > @Test  
> > > public void testIndexResponse() {
> > > 
> > > Client client = new TransportClient().setTransportAddress(new  
> > > InetSocketTransportAddress("localhost", 9300));
> > > 
> > > String json = "{" +  
> > > ""user":"kimchy"," +  
> > > ""postDate":"2013-01-30"," +  
> > > ""message":"trying out Elasticsearch"" +  
> > > "}";
> > > 
> > > IndexResponse response = client.prepareIndex("twitter", "tweet")  
> > > .setSource(json)  
> > > .execute()  
> > > .actionGet();
> > > 
> > > client.close();
> > > 
> > > System.out.println(response.getIndex());  
> > > }
> > > 
> > > I receive org.elasticsearch.client.transport.NoNodeAvailableException:  
> > > None of the configured nodes are available: .
> > > 
> > > On Monday, August 11, 2014 1:19:06 PM UTC-4, Vivek Sachdeva wrote:
> > > 
> > > > Have you tried using transport client for connecting...
> > > > 
> > > > On Monday, August 11, 2014 10:26:29 PM UTC+5:30, Kfeenz wrote:
> > > > 
> > > > > All,
> > > > > 
> > > > > I know this post is old, but I continue to have an issue with this...
> > > > > 
> > > > > I get an NoSuchMethodError: org.apache.log4j.Logger.isTraceEnabled()Z  
> > > > > exception when I run
> > > > > 
> > > > > Node node = NodeBuilder.nodeBuilder().local(true).node(); //  
> > > > > exception thrown here...  
> > > > > Client client = node.client();
> > > > > 
> > > > > I have tried including several different slf4j and log4j libraries...
> > > > > 
> > > > > Right now I have defined in my pom.xml:
> > > > > 
> > > > > slf4j-api-1.7.7.jar  
> > > > > slf4j-ext-1.7.7.jar  
> > > > > log4j-core-2.0.jar  
> > > > > log4j-api-2.0.jar
> > > > > 
> > > > > Any suggestions?  
> > > > > log4j-slf4j-impl-2.0.jar
> > > > > 
> > > > > On Wednesday, November 30, 2011 6:55:57 PM UTC-5, Sam wrote:
> > > > > 
> > > > > > All
> > > > > > 
> > > > > > I have a webapp (JAVA) with a list of items on the page. All these  
> > > > > > items are generated on html with session variables. I want to use  
> > > > > > Elasticsearch on the back end to do a search for items with different  
> > > > > > search criteria. Is there a sample I can use it as a resource?
> > > > > > 
> > > > > > Thanks
> > > > > > 
> > > > > > --  
> > > > > > 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).  
> > > > > > To view this discussion on the web visit  
> > > > > > [https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com)  
> > > > > > [https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > > .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoE1tA2Mss3C9NgYEc5Cv%2Bft9-CHz3aA\_zRpnwWy1RUYvQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoE1tA2Mss3C9NgYEc5Cv%2Bft9-CHz3aA_zRpnwWy1RUYvQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Vivek\_Sachdeva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vivek_sachdeva/32/1339_2.png) [@Vivek\_Sachdeva](https://discuss.elastic.co/u/Vivek_Sachdeva)\
**Post date:** [August 12, 2014, 4:03pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java/6032/16 "2014-08-12T16:03:26Z")

</div>

Your code works if you dont add cluster name to it..... Tried with Java  
this time.. 🙂

On Tue, Aug 12, 2014 at 7:47 PM, Kfeenz [kfeeney5506@gmail.com](mailto:kfeeney5506@gmail.com) wrote:

> @Jorg,
> 
> Thanks for the advice, I will make sure that I do so during actual  
> implementation, but this is purely for testing the connection.. Also, I see  
> a client.close() and a client.threadPool().shutdown(), but I do not see a  
> client.threadPool().close(). I am using ES v1.3.1.
> 
> @ Vivek,
> 
> I am not sure how you were able to use 'localhost' vise "localhost". Java  
> complains about an invalid character constant because 'localhost' is not a  
> character but a String...
> 
> My current code is as follows... with still no luck...
> 
> Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name",  
> "mycluster").build();
> 
> Client client = new TransportClient(settings).addTransportAddress(new  
> InetSocketTransportAddress("localhost", 9300));
> 
> ClusterStatsRequestBuilder builder =  
> client.admin().cluster().prepareClusterStats();
> 
> ClusterStatsResponse response = builder.execute().actionGet(); // fails on  
> execute... NoNodeAvailableException
> 
> assertEquals("mycluster", response.getClusterName()); // never gets to  
> this point
> 
> NoNodeAvailableException: None of the configured nodes are available
> 
> If I add a setting to the settings object
> 
> ```
> .put("client.transport.sniff", true);
> 
> ```
> 
> I get a different error - [org.elasticsearch.client.transport] [Argus]  
> failed to get local cluster state info for [#transport#-1]...
> 
> I can query the cluster using _[http://localhost:9200/\_cluster/health?pretty=true](http://localhost:9200/_cluster/health?pretty=true)  
> [http://localhost:9200/\_cluster/health?pretty=true](http://localhost:9200/_cluster/health?pretty=true)_ which returns
> 
> {  
> "cluster\_name" : "mycluster",  
> "status" : "green",  
> "timed\_out" : false,  
> "number\_of\_nodes" : 1,  
> "number\_of\_data\_nodes" : 1,  
> "active\_primary\_shards" : 0,  
> "active\_shards" : 0,  
> "relocating\_shards" : 0,  
> "initializing\_shards" : 0,  
> "unassigned\_shards" : 0  
> }
> 
> I am on Windows 7 64-bit.  
> I am using Java 1.7\_u55.  
> I am using ES version 1.3.1.  
> I have included in my pom.xml:
> 
> - elasticsearch-1.3.1.jar
> - lucene-core-4.9.0.jar
> 
> Any other suggestions are greatly appreciated.
> 
> On Tuesday, August 12, 2014 5:45:16 AM UTC-4, Vivek Sachdeva wrote:
> 
> > Replace
> > 
> > .setTransportAddress(new InetSocketTransportAddress("localhost", 9300));
> > 
> > with
> > 
> > .addTransportAddress(new InetSocketTransportAddress('localhost', 9300)).
> > 
> > And I guess if you dont give cluster name, it automatically joins the  
> > default cluster.
> > 
> > I tried the code that you provided and changed above mentioned code. It  
> > works on my end. Can you try it?
> > 
> > On Monday, August 11, 2014 11:34:43 PM UTC+5:30, Kfeenz wrote:
> > 
> > > So I am very new to elasticsearch... so I apologize in advance..
> > > 
> > > I started a local instance of elasticsearch and I am trying to connect  
> > > to it through the Java API.
> > > 
> > > I was under the impression that the transport client was for remote  
> > > clients?
> > > 
> > > I tried:
> > > 
> > > @Test  
> > > public void testIndexResponse() {
> > > 
> > > Client client = new TransportClient().setTransportAddress(new  
> > > InetSocketTransportAddress("localhost", 9300));
> > > 
> > > String json = "{" +  
> > > ""user":"kimchy"," +
> > > 
> > > ```
> > > "\"postDate\":\"2013-01-30\"," +
> > > "\"message\":\"trying out Elasticsearch\"" +
> > > 
> > > "}";
> > > 
> > > ```
> > > 
> > > IndexResponse response = client.prepareIndex("twitter", "tweet")
> > > 
> > > ```
> > > .setSource(json)
> > > .execute()
> > > .actionGet();
> > > 
> > > ```
> > > 
> > > client.close();
> > > 
> > > System.out.println(response.getIndex());  
> > > }
> > > 
> > > I receive org.elasticsearch.client.transport.NoNodeAvailableException:  
> > > None of the configured nodes are available: .
> > > 
> > > On Monday, August 11, 2014 1:19:06 PM UTC-4, Vivek Sachdeva wrote:
> > > 
> > > > Have you tried using transport client for connecting...
> > > > 
> > > > On Monday, August 11, 2014 10:26:29 PM UTC+5:30, Kfeenz wrote:
> > > > 
> > > > > All,
> > > > > 
> > > > > I know this post is old, but I continue to have an issue with this...
> > > > > 
> > > > > I get an NoSuchMethodError: org.apache.log4j.Logger.isTraceEnabled()Z  
> > > > > exception when I run
> > > > > 
> > > > > Node node = NodeBuilder.nodeBuilder().local(true).node(); //  
> > > > > exception thrown here...  
> > > > > Client client = node.client();
> > > > > 
> > > > > I have tried including several different slf4j and log4j libraries...
> > > > > 
> > > > > Right now I have defined in my pom.xml:
> > > > > 
> > > > > slf4j-api-1.7.7.jar  
> > > > > slf4j-ext-1.7.7.jar  
> > > > > log4j-core-2.0.jar  
> > > > > log4j-api-2.0.jar
> > > > > 
> > > > > Any suggestions?  
> > > > > log4j-slf4j-impl-2.0.jar
> > > > > 
> > > > > On Wednesday, November 30, 2011 6:55:57 PM UTC-5, Sam wrote:
> > > > > 
> > > > > > All
> > > > > > 
> > > > > > I have a webapp (JAVA) with a list of items on the page. All these  
> > > > > > items are generated on html with session variables. I want to use  
> > > > > > Elasticsearch on the back end to do a search for items with different  
> > > > > > search criteria. Is there a sample I can use it as a resource?
> > > > > > 
> > > > > > Thanks
> > > > > > 
> > > > > > --  
> > > > > > You received this message because you are subscribed to a topic in the  
> > > > > > Google Groups "elasticsearch" group.  
> > > > > > To unsubscribe from this topic, visit  
> > > > > > [https://groups.google.com/d/topic/elasticsearch/hl0P0NpCteQ/unsubscribe](https://groups.google.com/d/topic/elasticsearch/hl0P0NpCteQ/unsubscribe).  
> > > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > To view this discussion on the web visit  
> > > > > > [https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com)  
> > > > > > [https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > > .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Thanks & Regards.  
Vivek Sachdeva  
Intelligrape Software Pvt. Ltd.

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CABpbMD1\_b3c-EG6CW9Pd6SYOjQ0jr9ZsFdWVbZoMRtpkGgD3WQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CABpbMD1_b3c-EG6CW9Pd6SYOjQ0jr9ZsFdWVbZoMRtpkGgD3WQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Vivek\_Sachdeva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vivek_sachdeva/32/1339_2.png) [@Vivek\_Sachdeva](https://discuss.elastic.co/u/Vivek_Sachdeva)\
**Post date:** [August 12, 2014, 4:12pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java/6032/17 "2014-08-12T16:12:05Z")

</div>

The default cluster name is "elasticsearch". Changing it in your code  
works....

On Tue, Aug 12, 2014 at 9:33 PM, Vivek Sachdeva \<  
[vivek.sachdeva@intelligrape.com](mailto:vivek.sachdeva@intelligrape.com)\> wrote:

> Your code works if you dont add cluster name to it..... Tried with Java  
> this time.. 🙂
> 
> On Tue, Aug 12, 2014 at 7:47 PM, Kfeenz [kfeeney5506@gmail.com](mailto:kfeeney5506@gmail.com) wrote:
> 
> > @Jorg,
> > 
> > Thanks for the advice, I will make sure that I do so during actual  
> > implementation, but this is purely for testing the connection.. Also, I see  
> > a client.close() and a client.threadPool().shutdown(), but I do not see a  
> > client.threadPool().close(). I am using ES v1.3.1.
> > 
> > @ Vivek,
> > 
> > I am not sure how you were able to use 'localhost' vise "localhost". Java  
> > complains about an invalid character constant because 'localhost' is not a  
> > character but a String...
> > 
> > My current code is as follows... with still no luck...
> > 
> > Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name",  
> > "mycluster").build();
> > 
> > Client client = new TransportClient(settings).addTransportAddress(new  
> > InetSocketTransportAddress("localhost", 9300));
> > 
> > ClusterStatsRequestBuilder builder =  
> > client.admin().cluster().prepareClusterStats();
> > 
> > ClusterStatsResponse response = builder.execute().actionGet(); // fails  
> > on execute... NoNodeAvailableException
> > 
> > assertEquals("mycluster", response.getClusterName()); // never gets to  
> > this point
> > 
> > NoNodeAvailableException: None of the configured nodes are available
> > 
> > If I add a setting to the settings object
> > 
> > ```
> > .put("client.transport.sniff", true);
> > 
> > ```
> > 
> > I get a different error - [org.elasticsearch.client.transport] [Argus]  
> > failed to get local cluster state info for [#transport#-1]...
> > 
> > I can query the cluster using _[http://localhost:9200/\_cluster/health?pretty=true](http://localhost:9200/_cluster/health?pretty=true)  
> > [http://localhost:9200/\_cluster/health?pretty=true](http://localhost:9200/_cluster/health?pretty=true)_ which returns
> > 
> > {  
> > "cluster\_name" : "mycluster",  
> > "status" : "green",  
> > "timed\_out" : false,  
> > "number\_of\_nodes" : 1,  
> > "number\_of\_data\_nodes" : 1,  
> > "active\_primary\_shards" : 0,  
> > "active\_shards" : 0,  
> > "relocating\_shards" : 0,  
> > "initializing\_shards" : 0,  
> > "unassigned\_shards" : 0  
> > }
> > 
> > I am on Windows 7 64-bit.  
> > I am using Java 1.7\_u55.  
> > I am using ES version 1.3.1.  
> > I have included in my pom.xml:
> > 
> > - elasticsearch-1.3.1.jar
> > - lucene-core-4.9.0.jar
> > 
> > Any other suggestions are greatly appreciated.
> > 
> > On Tuesday, August 12, 2014 5:45:16 AM UTC-4, Vivek Sachdeva wrote:
> > 
> > > Replace
> > > 
> > > .setTransportAddress(new InetSocketTransportAddress("localhost",  
> > > 9300));
> > > 
> > > with
> > > 
> > > .addTransportAddress(new InetSocketTransportAddress('localhost', 9300)).
> > > 
> > > And I guess if you dont give cluster name, it automatically joins the  
> > > default cluster.
> > > 
> > > I tried the code that you provided and changed above mentioned code. It  
> > > works on my end. Can you try it?
> > > 
> > > On Monday, August 11, 2014 11:34:43 PM UTC+5:30, Kfeenz wrote:
> > > 
> > > > So I am very new to elasticsearch... so I apologize in advance..
> > > > 
> > > > I started a local instance of elasticsearch and I am trying to connect  
> > > > to it through the Java API.
> > > > 
> > > > I was under the impression that the transport client was for remote  
> > > > clients?
> > > > 
> > > > I tried:
> > > > 
> > > > @Test  
> > > > public void testIndexResponse() {
> > > > 
> > > > Client client = new TransportClient().setTransportAddress(new  
> > > > InetSocketTransportAddress("localhost", 9300));
> > > > 
> > > > String json = "{" +  
> > > > ""user":"kimchy"," +
> > > > 
> > > > ```
> > > > "\"postDate\":\"2013-01-30\"," +
> > > > "\"message\":\"trying out Elasticsearch\"" +
> > > > 
> > > > "}";
> > > > 
> > > > ```
> > > > 
> > > > IndexResponse response = client.prepareIndex("twitter", "tweet")
> > > > 
> > > > ```
> > > > .setSource(json)
> > > > .execute()
> > > > .actionGet();
> > > > 
> > > > ```
> > > > 
> > > > client.close();
> > > > 
> > > > System.out.println(response.getIndex());  
> > > > }
> > > > 
> > > > I receive org.elasticsearch.client.transport.NoNodeAvailableException:  
> > > > None of the configured nodes are available: .
> > > > 
> > > > On Monday, August 11, 2014 1:19:06 PM UTC-4, Vivek Sachdeva wrote:
> > > > 
> > > > > Have you tried using transport client for connecting...
> > > > > 
> > > > > On Monday, August 11, 2014 10:26:29 PM UTC+5:30, Kfeenz wrote:
> > > > > 
> > > > > > All,
> > > > > > 
> > > > > > I know this post is old, but I continue to have an issue with this...
> > > > > > 
> > > > > > I get an NoSuchMethodError: org.apache.log4j.Logger.isTraceEnabled()Z  
> > > > > > exception when I run
> > > > > > 
> > > > > > Node node = NodeBuilder.nodeBuilder().local(true).node(); //  
> > > > > > exception thrown here...  
> > > > > > Client client = node.client();
> > > > > > 
> > > > > > I have tried including several different slf4j and log4j libraries...
> > > > > > 
> > > > > > Right now I have defined in my pom.xml:
> > > > > > 
> > > > > > slf4j-api-1.7.7.jar  
> > > > > > slf4j-ext-1.7.7.jar  
> > > > > > log4j-core-2.0.jar  
> > > > > > log4j-api-2.0.jar
> > > > > > 
> > > > > > Any suggestions?  
> > > > > > log4j-slf4j-impl-2.0.jar
> > > > > > 
> > > > > > On Wednesday, November 30, 2011 6:55:57 PM UTC-5, Sam wrote:
> > > > > > 
> > > > > > > All
> > > > > > > 
> > > > > > > I have a webapp (JAVA) with a list of items on the page. All these  
> > > > > > > items are generated on html with session variables. I want to use  
> > > > > > > Elasticsearch on the back end to do a search for items with different  
> > > > > > > search criteria. Is there a sample I can use it as a resource?
> > > > > > > 
> > > > > > > Thanks
> > > > > > > 
> > > > > > > --  
> > > > > > > You received this message because you are subscribed to a topic in the  
> > > > > > > Google Groups "elasticsearch" group.  
> > > > > > > To unsubscribe from this topic, visit  
> > > > > > > [https://groups.google.com/d/topic/elasticsearch/hl0P0NpCteQ/unsubscribe](https://groups.google.com/d/topic/elasticsearch/hl0P0NpCteQ/unsubscribe).  
> > > > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > > > > > To view this discussion on the web visit  
> > > > > > > [https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com)  
> > > > > > > [https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > > > .
> > 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> Thanks & Regards.  
> Vivek Sachdeva  
> Intelligrape Software Pvt. Ltd.

--  
Thanks & Regards.  
Vivek Sachdeva  
Intelligrape Software Pvt. Ltd.

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CABpbMD27qxADRUfjr1DpZh%3D8sWT\_i9a4b14A%2B%3DBKMW41maSyPg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CABpbMD27qxADRUfjr1DpZh%3D8sWT_i9a4b14A%2B%3DBKMW41maSyPg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![feenz](https://avatars.discourse-cdn.com/v4/letter/f/4bbf92/32.png) [@feenz](https://discuss.elastic.co/u/feenz)\
**Post date:** [August 12, 2014, 5:48pm UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java/6032/18 "2014-08-12T17:48:52Z")

</div>

I must be doing something wrong.... I continue to get the same error.... I  
removed the cluster.name in the settings and still get the same error.

Elasticsearch is running on the same machine that I am trying to connect  
with the client. Is TransportClient the correct way to connect? Or should I  
be using Node?

I tried this....

Node node =  
nodeBuilder().client(true).loadConfigSettings(false).settings(settings).node();

This returns the error NoSuchMethodError: java.lang.NoSuchMethodError:  
org.apache.log4j.Logger.isTraceEnabled()Z at  
org.elasticsearch.common.logging.log4j.Log4jESLogger.isTraceEnabled()

I have included the log4j-1.4.0.jar that came packaged with the version of  
elasticsearch-1.3.1 ....

On Tue, Aug 12, 2014 at 12:13 PM, Vivek Sachdeva [via Elasticsearch Users] \<  
[ml-node+s115913n4061741h25@n3.nabble.com](mailto:ml-node+s115913n4061741h25@n3.nabble.com)\> wrote:

> The default cluster name is "elasticsearch". Changing it in your code  
> works....
> 
> On Tue, Aug 12, 2014 at 9:33 PM, Vivek Sachdeva \<[hidden email]  
> [http://user/SendEmail.jtp?type=node&node=4061741&i=0](http://user/SendEmail.jtp?type=node&node=4061741&i=0)\> wrote:
> 
> > Your code works if you dont add cluster name to it..... Tried with Java  
> > this time.. 🙂
> > 
> > On Tue, Aug 12, 2014 at 7:47 PM, Kfeenz \<[hidden email]  
> > [http://user/SendEmail.jtp?type=node&node=4061741&i=1](http://user/SendEmail.jtp?type=node&node=4061741&i=1)\> wrote:
> > 
> > > @Jorg,
> > > 
> > > Thanks for the advice, I will make sure that I do so during actual  
> > > implementation, but this is purely for testing the connection.. Also, I see  
> > > a client.close() and a client.threadPool().shutdown(), but I do not see a  
> > > client.threadPool().close(). I am using ES v1.3.1.
> > > 
> > > @ Vivek,
> > > 
> > > I am not sure how you were able to use 'localhost' vise "localhost".  
> > > Java complains about an invalid character constant because 'localhost' is  
> > > not a character but a String...
> > > 
> > > My current code is as follows... with still no luck...
> > > 
> > > Settings settings = ImmutableSettings.settingsBuilder().put("  
> > > cluster.name", "mycluster").build();
> > > 
> > > Client client = new TransportClient(settings).addTransportAddress(new  
> > > InetSocketTransportAddress("localhost", 9300));
> > > 
> > > ClusterStatsRequestBuilder builder =  
> > > client.admin().cluster().prepareClusterStats();
> > > 
> > > ClusterStatsResponse response = builder.execute().actionGet(); // fails  
> > > on execute... NoNodeAvailableException
> > > 
> > > assertEquals("mycluster", response.getClusterName()); // never gets to  
> > > this point
> > > 
> > > NoNodeAvailableException: None of the configured nodes are available
> > > 
> > > If I add a setting to the settings object
> > > 
> > > ```
> > > .put("client.transport.sniff", true);
> > > 
> > > ```
> > > 
> > > I get a different error - [org.elasticsearch.client.transport] [Argus]  
> > > failed to get local cluster state info for [#transport#-1]...
> > > 
> > > I can query the cluster using _[http://localhost:9200/\_cluster/health?pretty=true](http://localhost:9200/_cluster/health?pretty=true)  
> > > [http://localhost:9200/\_cluster/health?pretty=true](http://localhost:9200/_cluster/health?pretty=true)_ which returns
> > > 
> > > {  
> > > "cluster\_name" : "mycluster",  
> > > "status" : "green",  
> > > "timed\_out" : false,  
> > > "number\_of\_nodes" : 1,  
> > > "number\_of\_data\_nodes" : 1,  
> > > "active\_primary\_shards" : 0,  
> > > "active\_shards" : 0,  
> > > "relocating\_shards" : 0,  
> > > "initializing\_shards" : 0,  
> > > "unassigned\_shards" : 0  
> > > }
> > > 
> > > I am on Windows 7 64-bit.  
> > > I am using Java 1.7\_u55.  
> > > I am using ES version 1.3.1.  
> > > I have included in my pom.xml:
> > > 
> > > - elasticsearch-1.3.1.jar
> > > - lucene-core-4.9.0.jar
> > > 
> > > Any other suggestions are greatly appreciated.
> > > 
> > > On Tuesday, August 12, 2014 5:45:16 AM UTC-4, Vivek Sachdeva wrote:
> > > 
> > > > Replace
> > > > 
> > > > .setTransportAddress(new InetSocketTransportAddress("localhost",  
> > > > 9300));
> > > > 
> > > > with
> > > > 
> > > > .addTransportAddress(new InetSocketTransportAddress('localhost',  
> > > > 9300)).
> > > > 
> > > > And I guess if you dont give cluster name, it automatically joins the  
> > > > default cluster.
> > > > 
> > > > I tried the code that you provided and changed above mentioned code. It  
> > > > works on my end. Can you try it?
> > > > 
> > > > On Monday, August 11, 2014 11:34:43 PM UTC+5:30, Kfeenz wrote:
> > > > 
> > > > > So I am very new to elasticsearch... so I apologize in advance..
> > > > > 
> > > > > I started a local instance of elasticsearch and I am trying to connect  
> > > > > to it through the Java API.
> > > > > 
> > > > > I was under the impression that the transport client was for remote  
> > > > > clients?
> > > > > 
> > > > > I tried:
> > > > > 
> > > > > @Test  
> > > > > public void testIndexResponse() {
> > > > > 
> > > > > Client client = new TransportClient().setTransportAddress(new  
> > > > > InetSocketTransportAddress("localhost", 9300));
> > > > > 
> > > > > String json = "{" +  
> > > > > ""user":"kimchy"," +
> > > > > 
> > > > > ```
> > > > > "\"postDate\":\"2013-01-30\"," +
> > > > > "\"message\":\"trying out Elasticsearch\"" +
> > > > > 
> > > > > "}";
> > > > > 
> > > > > ```
> > > > > 
> > > > > IndexResponse response = client.prepareIndex("twitter", "tweet")
> > > > > 
> > > > > ```
> > > > > .setSource(json)
> > > > > .execute()
> > > > > .actionGet();
> > > > > 
> > > > > ```
> > > > > 
> > > > > client.close();
> > > > > 
> > > > > System.out.println(response.getIndex());  
> > > > > }
> > > > > 
> > > > > I receive org.elasticsearch.client.transport.NoNodeAvailableException:  
> > > > > None of the configured nodes are available: .
> > > > > 
> > > > > On Monday, August 11, 2014 1:19:06 PM UTC-4, Vivek Sachdeva wrote:
> > > > > 
> > > > > > Have you tried using transport client for connecting...
> > > > > > 
> > > > > > On Monday, August 11, 2014 10:26:29 PM UTC+5:30, Kfeenz wrote:
> > > > > > 
> > > > > > > All,
> > > > > > > 
> > > > > > > I know this post is old, but I continue to have an issue with  
> > > > > > > this...
> > > > > > > 
> > > > > > > I get an NoSuchMethodError: org.apache.log4j.Logger.isTraceEnabled()Z  
> > > > > > > exception when I run
> > > > > > > 
> > > > > > > Node node = NodeBuilder.nodeBuilder().local(true).node(); //  
> > > > > > > exception thrown here...  
> > > > > > > Client client = node.client();
> > > > > > > 
> > > > > > > I have tried including several different slf4j and log4j libraries...
> > > > > > > 
> > > > > > > Right now I have defined in my pom.xml:
> > > > > > > 
> > > > > > > slf4j-api-1.7.7.jar  
> > > > > > > slf4j-ext-1.7.7.jar  
> > > > > > > log4j-core-2.0.jar  
> > > > > > > log4j-api-2.0.jar
> > > > > > > 
> > > > > > > Any suggestions?  
> > > > > > > log4j-slf4j-impl-2.0.jar
> > > > > > > 
> > > > > > > On Wednesday, November 30, 2011 6:55:57 PM UTC-5, Sam wrote:
> > > > > > > 
> > > > > > > > All
> > > > > > > > 
> > > > > > > > I have a webapp (JAVA) with a list of items on the page. All these  
> > > > > > > > items are generated on html with session variables. I want to use  
> > > > > > > > Elasticsearch on the back end to do a search for items with  
> > > > > > > > different  
> > > > > > > > search criteria. Is there a sample I can use it as a resource?
> > > > > > > > 
> > > > > > > > Thanks
> > > > > > > > 
> > > > > > > > --  
> > > > > > > > You received this message because you are subscribed to a topic in the  
> > > > > > > > Google Groups "elasticsearch" group.  
> > > > > > > > To unsubscribe from this topic, visit  
> > > > > > > > [https://groups.google.com/d/topic/elasticsearch/hl0P0NpCteQ/unsubscribe](https://groups.google.com/d/topic/elasticsearch/hl0P0NpCteQ/unsubscribe).  
> > > > > > > > To unsubscribe from this group and all its topics, send an email to [hidden  
> > > > > > > > email] [http://user/SendEmail.jtp?type=node&node=4061741&i=2](http://user/SendEmail.jtp?type=node&node=4061741&i=2).  
> > > > > > > > To view this discussion on the web visit  
> > > > > > > > [https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com)  
> > > > > > > > [https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > > > > .
> > > 
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > Thanks & Regards.  
> > Vivek Sachdeva  
> > Intelligrape Software Pvt. Ltd.
> 
> --  
> Thanks & Regards.  
> Vivek Sachdeva  
> Intelligrape Software Pvt. Ltd.
> 
> --  
> 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 [hidden email]  
> [http://user/SendEmail.jtp?type=node&node=4061741&i=3](http://user/SendEmail.jtp?type=node&node=4061741&i=3).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CABpbMD27qxADRUfjr1DpZh%3D8sWT\_i9a4b14A%2B%3DBKMW41maSyPg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CABpbMD27qxADRUfjr1DpZh%3D8sWT_i9a4b14A%2B%3DBKMW41maSyPg%40mail.gmail.com)  
> [https://groups.google.com/d/msgid/elasticsearch/CABpbMD27qxADRUfjr1DpZh%3D8sWT\_i9a4b14A%2B%3DBKMW41maSyPg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CABpbMD27qxADRUfjr1DpZh%3D8sWT_i9a4b14A%2B%3DBKMW41maSyPg%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> * * *
> 
> If you reply to this email, your message will be added to the discussion  
> below:
> 
> [http://elasticsearch-users.115913.n3.nabble.com/Embedded-ElasticSearch-On-Java-tp3550161p4061741.html](http://elasticsearch-users.115913.n3.nabble.com/Embedded-ElasticSearch-On-Java-tp3550161p4061741.html)  
> To unsubscribe from Embedded Elasticsearch On Java, click here  
> [http://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe\_by\_code&node=3550161&code=a2ZlZW5leTU1MDZAZ21haWwuY29tfDM1NTAxNjF8LTc5Mzg5NTUyMg==](http://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3550161&code=a2ZlZW5leTU1MDZAZ21haWwuY29tfDM1NTAxNjF8LTc5Mzg5NTUyMg==)  
> .  
> NAML  
> [http://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet.jtp?macro=macro\_viewer&id=instant\_html!nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify\_subscribers!nabble%3Aemail.naml-instant\_emails!nabble%3Aemail.naml-send\_instant\_email!nabble%3Aemail.naml](http://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml)

---

<div class="post-metadata">

**Author:** ![Vivek\_Sachdeva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vivek_sachdeva/32/1339_2.png) [@Vivek\_Sachdeva](https://discuss.elastic.co/u/Vivek_Sachdeva)\
**Post date:** [August 13, 2014, 10:07am UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java/6032/19 "2014-08-13T10:07:24Z")

</div>

If your project is not really big, maybe you can send it here or directly...

[vivek.sachdeva@intelligrape.com](mailto:vivek.sachdeva@intelligrape.com)

On Tue, Aug 12, 2014 at 11:19 PM, feenz [kfeeney5506@gmail.com](mailto:kfeeney5506@gmail.com) wrote:

> I must be doing something wrong.... I continue to get the same error.... I  
> removed the cluster.name in the settings and still get the same error.
> 
> Elasticsearch is running on the same machine that I am trying to connect  
> with the client. Is TransportClient the correct way to connect? Or should I  
> be using Node?
> 
> I tried this....
> 
> Node node =  
> nodeBuilder().client(true).loadConfigSettings(false).settings(settings).node();
> 
> This returns the error NoSuchMethodError: java.lang.NoSuchMethodError:  
> org.apache.log4j.Logger.isTraceEnabled()Z at  
> org.elasticsearch.common.logging.log4j.Log4jESLogger.isTraceEnabled()
> 
> I have included the log4j-1.4.0.jar that came packaged with the version of  
> elasticsearch-1.3.1 ....
> 
> On Tue, Aug 12, 2014 at 12:13 PM, Vivek Sachdeva [via Elasticsearch Users]  
> \<[hidden email] [http://user/SendEmail.jtp?type=node&node=4061750&i=0](http://user/SendEmail.jtp?type=node&node=4061750&i=0)\>  
> wrote:
> 
> > The default cluster name is "elasticsearch". Changing it in your code  
> > works....
> > 
> > On Tue, Aug 12, 2014 at 9:33 PM, Vivek Sachdeva \<[hidden email]  
> > [http://user/SendEmail.jtp?type=node&node=4061741&i=0](http://user/SendEmail.jtp?type=node&node=4061741&i=0)\> wrote:
> > 
> > > Your code works if you dont add cluster name to it..... Tried with Java  
> > > this time.. 🙂
> > > 
> > > On Tue, Aug 12, 2014 at 7:47 PM, Kfeenz \<[hidden email]  
> > > [http://user/SendEmail.jtp?type=node&node=4061741&i=1](http://user/SendEmail.jtp?type=node&node=4061741&i=1)\> wrote:
> > > 
> > > > @Jorg,
> > > > 
> > > > Thanks for the advice, I will make sure that I do so during actual  
> > > > implementation, but this is purely for testing the connection.. Also, I see  
> > > > a client.close() and a client.threadPool().shutdown(), but I do not see a  
> > > > client.threadPool().close(). I am using ES v1.3.1.
> > > > 
> > > > @ Vivek,
> > > > 
> > > > I am not sure how you were able to use 'localhost' vise "localhost".  
> > > > Java complains about an invalid character constant because 'localhost' is  
> > > > not a character but a String...
> > > > 
> > > > My current code is as follows... with still no luck...
> > > > 
> > > > Settings settings = ImmutableSettings.settingsBuilder().put("  
> > > > cluster.name", "mycluster").build();
> > > > 
> > > > Client client = new TransportClient(settings).addTransportAddress(new  
> > > > InetSocketTransportAddress("localhost", 9300));
> > > > 
> > > > ClusterStatsRequestBuilder builder =  
> > > > client.admin().cluster().prepareClusterStats();
> > > > 
> > > > ClusterStatsResponse response = builder.execute().actionGet(); // fails  
> > > > on execute... NoNodeAvailableException
> > > > 
> > > > assertEquals("mycluster", response.getClusterName()); // never gets to  
> > > > this point
> > > > 
> > > > NoNodeAvailableException: None of the configured nodes are available
> > > > 
> > > > If I add a setting to the settings object
> > > > 
> > > > ```
> > > > .put("client.transport.sniff", true);
> > > > 
> > > > ```
> > > > 
> > > > I get a different error - [org.elasticsearch.client.transport] [Argus]  
> > > > failed to get local cluster state info for [#transport#-1]...
> > > > 
> > > > I can query the cluster using _[http://localhost:9200/\_cluster/health?pretty=true](http://localhost:9200/_cluster/health?pretty=true)  
> > > > [http://localhost:9200/\_cluster/health?pretty=true](http://localhost:9200/_cluster/health?pretty=true)_ which returns
> > > > 
> > > > {  
> > > > "cluster\_name" : "mycluster",  
> > > > "status" : "green",  
> > > > "timed\_out" : false,  
> > > > "number\_of\_nodes" : 1,  
> > > > "number\_of\_data\_nodes" : 1,  
> > > > "active\_primary\_shards" : 0,  
> > > > "active\_shards" : 0,  
> > > > "relocating\_shards" : 0,  
> > > > "initializing\_shards" : 0,  
> > > > "unassigned\_shards" : 0  
> > > > }
> > > > 
> > > > I am on Windows 7 64-bit.  
> > > > I am using Java 1.7\_u55.  
> > > > I am using ES version 1.3.1.  
> > > > I have included in my pom.xml:
> > > > 
> > > > - elasticsearch-1.3.1.jar
> > > > - lucene-core-4.9.0.jar
> > > > 
> > > > Any other suggestions are greatly appreciated.
> > > > 
> > > > On Tuesday, August 12, 2014 5:45:16 AM UTC-4, Vivek Sachdeva wrote:
> > > > 
> > > > > Replace
> > > > > 
> > > > > .setTransportAddress(new InetSocketTransportAddress("localhost",  
> > > > > 9300));
> > > > > 
> > > > > with
> > > > > 
> > > > > .addTransportAddress(new InetSocketTransportAddress('localhost',  
> > > > > 9300)).
> > > > > 
> > > > > And I guess if you dont give cluster name, it automatically joins the  
> > > > > default cluster.
> > > > > 
> > > > > I tried the code that you provided and changed above mentioned code.  
> > > > > It works on my end. Can you try it?
> > > > > 
> > > > > On Monday, August 11, 2014 11:34:43 PM UTC+5:30, Kfeenz wrote:
> > > > > 
> > > > > > So I am very new to elasticsearch... so I apologize in advance..
> > > > > > 
> > > > > > I started a local instance of elasticsearch and I am trying to  
> > > > > > connect to it through the Java API.
> > > > > > 
> > > > > > I was under the impression that the transport client was for remote  
> > > > > > clients?
> > > > > > 
> > > > > > I tried:
> > > > > > 
> > > > > > @Test  
> > > > > > public void testIndexResponse() {
> > > > > > 
> > > > > > Client client = new TransportClient().setTransportAddress(new  
> > > > > > InetSocketTransportAddress("localhost", 9300));
> > > > > > 
> > > > > > String json = "{" +  
> > > > > > ""user":"kimchy"," +
> > > > > > 
> > > > > > ```
> > > > > > "\"postDate\":\"2013-01-30\"," +
> > > > > > "\"message\":\"trying out Elasticsearch\"" +
> > > > > > 
> > > > > > "}";
> > > > > > 
> > > > > > ```
> > > > > > 
> > > > > > IndexResponse response = client.prepareIndex("twitter", "tweet")
> > > > > > 
> > > > > > ```
> > > > > > .setSource(json)
> > > > > > .execute()
> > > > > > .actionGet();
> > > > > > 
> > > > > > ```
> > > > > > 
> > > > > > client.close();
> > > > > > 
> > > > > > System.out.println(response.getIndex());  
> > > > > > }
> > > > > > 
> > > > > > I receive org.elasticsearch.client.transport.NoNodeAvailableException:  
> > > > > > None of the configured nodes are available: .
> > > > > > 
> > > > > > On Monday, August 11, 2014 1:19:06 PM UTC-4, Vivek Sachdeva wrote:
> > > > > > 
> > > > > > > Have you tried using transport client for connecting...
> > > > > > > 
> > > > > > > On Monday, August 11, 2014 10:26:29 PM UTC+5:30, Kfeenz wrote:
> > > > > > > 
> > > > > > > > All,
> > > > > > > > 
> > > > > > > > I know this post is old, but I continue to have an issue with  
> > > > > > > > this...
> > > > > > > > 
> > > > > > > > I get an NoSuchMethodError: org.apache.log4j.Logger.isTraceEnabled()Z  
> > > > > > > > exception when I run
> > > > > > > > 
> > > > > > > > Node node = NodeBuilder.nodeBuilder().local(true).node(); //  
> > > > > > > > exception thrown here...  
> > > > > > > > Client client = node.client();
> > > > > > > > 
> > > > > > > > I have tried including several different slf4j and log4j  
> > > > > > > > libraries...
> > > > > > > > 
> > > > > > > > Right now I have defined in my pom.xml:
> > > > > > > > 
> > > > > > > > slf4j-api-1.7.7.jar  
> > > > > > > > slf4j-ext-1.7.7.jar  
> > > > > > > > log4j-core-2.0.jar  
> > > > > > > > log4j-api-2.0.jar
> > > > > > > > 
> > > > > > > > Any suggestions?  
> > > > > > > > log4j-slf4j-impl-2.0.jar
> > > > > > > > 
> > > > > > > > On Wednesday, November 30, 2011 6:55:57 PM UTC-5, Sam wrote:
> > > > > > > > 
> > > > > > > > > All
> > > > > > > > > 
> > > > > > > > > I have a webapp (JAVA) with a list of items on the page. All these  
> > > > > > > > > items are generated on html with session variables. I want to use  
> > > > > > > > > Elasticsearch on the back end to do a search for items with  
> > > > > > > > > different  
> > > > > > > > > search criteria. Is there a sample I can use it as a resource?
> > > > > > > > > 
> > > > > > > > > Thanks
> > > > > > > > > 
> > > > > > > > > --  
> > > > > > > > > You received this message because you are subscribed to a topic in the  
> > > > > > > > > Google Groups "elasticsearch" group.  
> > > > > > > > > To unsubscribe from this topic, visit  
> > > > > > > > > [https://groups.google.com/d/topic/elasticsearch/hl0P0NpCteQ/unsubscribe](https://groups.google.com/d/topic/elasticsearch/hl0P0NpCteQ/unsubscribe)  
> > > > > > > > > .  
> > > > > > > > > To unsubscribe from this group and all its topics, send an email to [hidden  
> > > > > > > > > email] [http://user/SendEmail.jtp?type=node&node=4061741&i=2](http://user/SendEmail.jtp?type=node&node=4061741&i=2).  
> > > > > > > > > To view this discussion on the web visit  
> > > > > > > > > [https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com)  
> > > > > > > > > [https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/090eaed6-ce13-4460-8db1-b6913e6f1582%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > > > > > .
> > > > 
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --  
> > > Thanks & Regards.  
> > > Vivek Sachdeva  
> > > Intelligrape Software Pvt. Ltd.
> > 
> > --  
> > Thanks & Regards.  
> > Vivek Sachdeva  
> > Intelligrape Software Pvt. Ltd.
> > 
> > --  
> > 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 [hidden email]  
> > [http://user/SendEmail.jtp?type=node&node=4061741&i=3](http://user/SendEmail.jtp?type=node&node=4061741&i=3).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/CABpbMD27qxADRUfjr1DpZh%3D8sWT\_i9a4b14A%2B%3DBKMW41maSyPg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CABpbMD27qxADRUfjr1DpZh%3D8sWT_i9a4b14A%2B%3DBKMW41maSyPg%40mail.gmail.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/CABpbMD27qxADRUfjr1DpZh%3D8sWT\_i9a4b14A%2B%3DBKMW41maSyPg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CABpbMD27qxADRUfjr1DpZh%3D8sWT_i9a4b14A%2B%3DBKMW41maSyPg%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > .
> > 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > * * *
> > 
> > If you reply to this email, your message will be added to the  
> > discussion below:
> > 
> > [http://elasticsearch-users.115913.n3.nabble.com/Embedded-ElasticSearch-On-Java-tp3550161p4061741.html](http://elasticsearch-users.115913.n3.nabble.com/Embedded-ElasticSearch-On-Java-tp3550161p4061741.html)  
> > To unsubscribe from Embedded Elasticsearch On Java, click here.  
> > NAML  
> > [http://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet.jtp?macro=macro\_viewer&id=instant\_html!nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify\_subscribers!nabble%3Aemail.naml-instant\_emails!nabble%3Aemail.naml-send\_instant\_email!nabble%3Aemail.naml](http://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml)
> 
> * * *
> 
> View this message in context: Re: Embedded Elasticsearch On Java  
> [http://elasticsearch-users.115913.n3.nabble.com/Embedded-ElasticSearch-On-Java-tp3550161p4061750.html](http://elasticsearch-users.115913.n3.nabble.com/Embedded-ElasticSearch-On-Java-tp3550161p4061750.html)  
> Sent from the Elasticsearch Users mailing list archive  
> [http://elasticsearch-users.115913.n3.nabble.com/](http://elasticsearch-users.115913.n3.nabble.com/) at [Nabble.com](http://Nabble.com).
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/hl0P0NpCteQ/unsubscribe](https://groups.google.com/d/topic/elasticsearch/hl0P0NpCteQ/unsubscribe).  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CADLVcFs6WWazmzgqxs5-KBCZdt2%2BQEG1whJNvbX7fvFo14sSFg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CADLVcFs6WWazmzgqxs5-KBCZdt2%2BQEG1whJNvbX7fvFo14sSFg%40mail.gmail.com)  
> [https://groups.google.com/d/msgid/elasticsearch/CADLVcFs6WWazmzgqxs5-KBCZdt2%2BQEG1whJNvbX7fvFo14sSFg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CADLVcFs6WWazmzgqxs5-KBCZdt2%2BQEG1whJNvbX7fvFo14sSFg%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Thanks & Regards.  
Vivek Sachdeva  
Intelligrape Software Pvt. Ltd.

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CABpbMD2pScgRzCAPN0vwmnSTqPj%3DDVueg1T5%3DkQ3PoGfs%2Bu%3DDA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CABpbMD2pScgRzCAPN0vwmnSTqPj%3DDVueg1T5%3DkQ3PoGfs%2Bu%3DDA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:08am UTC](https://discuss.elastic.co/t/embedded-elasticsearch-on-java/6032/20 "2017-07-06T01:08:59Z")

</div>


