# Java Client

**URL:** https://discuss.elastic.co/t/java-client/6972
**Category:** Elasticsearch
**Created:** [March 13, 2012, 7:43am UTC](https://discuss.elastic.co/t/java-client/6972 "2012-03-13T07:43:41Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![ksquare\_2](https://avatars.discourse-cdn.com/v4/letter/k/9fc348/32.png) [@ksquare\_2](https://discuss.elastic.co/u/ksquare_2)
#### Post date: [March 13, 2012, 7:43am UTC](https://discuss.elastic.co/t/java-client/6972/1 "2012-03-13T07:43:41Z")

</div>

I am a newbie in Elasticsearch. I am trying to create a Java client  
that connects to the Elasticsearch version 0.19.0 started via Cygwin.

Below is my sample code:

```
public static void main(String[] args) {

	Node node = nodeBuilder().client(true).node();
	Client client = new TransportClient()
			.addTransportAddress(new InetSocketTransportAddress(
					"127.0.0.1", 9300));
	try {
		IndexResponse response = client
				.prepareIndex("twitter", "tweet", "1")
				.setSource(
						jsonBuilder()
								.startObject()
								.field("user", "kimchy")
								.field("postDate", new Date())
								.field("message",
										"trying out Elastic Search")
								.endObject()).execute().actionGet();
	} catch (ElasticSearchException e) {

		e.printStackTrace();
	} catch (IOException e) {

		e.printStackTrace();
	}

	node.close();

}

```

However, when I run this test, I get the following error from running  
"Node node = nodeBuilder().client(true).node();"

[2012-03-13 00:34:18,712][WARN][discovery.zen.ping.multicast] [Pitt,  
Desmond] failed to read requesting data from  
org.elasticsearch.ElasticSearchIllegalStateException: failed  
multicastmessage, probably message from previous version at  
org.elasticsearch.discovery.zen.ping.multicast.MulticastZenPing  
$Receiver.run(MulticastZenPing.java:406) at  
java.lang.Thread.run(Thread.java:722)

What did I do wrong?

Thanks!

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [March 13, 2012, 7:57am UTC](https://discuss.elastic.co/t/java-client/6972/2 "2012-03-13T07:57:59Z")

</div>

There's two way to connect to an ES cluster.

1. You start a client node and then ask the node to give you a client.
2. You create a simple transport client

Here you mixes the two ways.

If you want to use a node, your second line should be :  
Client client = node . client ();

Did you modify settings for your ES node started with cygwin ?  
BTW, why don't you start it with the windows elasticsearch command line ?

HTH  
David.

Le 13 mars 2012 à 08:43, ksquare [ksquaredot@gmail.com](mailto:ksquaredot@gmail.com) a écrit :

> I am a newbie in Elasticsearch. I am trying to create a Java client  
> that connects to the Elasticsearch version 0.19.0 started via Cygwin.
> 
> Below is my sample code:
> 
> ```
> public static void main(String[] args) {
> 
> Node node = nodeBuilder().client(true).node();
> Client client = new TransportClient()
> .addTransportAddress(new
> 
> ```

InetSocketTransportAddress(

> ```
> "127.0.0.1", 9300));
> try {
> IndexResponse response = client
> .prepareIndex("twitter", "tweet",
> 
> ```

"1")

> ```
> .setSource(
> jsonBuilder()
> 
> ```

.startObject()

> 

.field("user", "kimchy")

> 

.field("postDate", new Date())

> 

.field("message",

> 

```
          "trying out Elastic Search")

```

> 

.endObject()).execute().actionGet();

> ```
> } catch (ElasticSearchException e) {
> 
> e.printStackTrace();
> } catch (IOException e) {
> 
> e.printStackTrace();
> }
> 
> node.close();
> 
> }
> 
> ```
> 
> However, when I run this test, I get the following error from running  
> "Node node = nodeBuilder().client(true).node();"
> 
> [2012-03-13 00:34:18,712][WARN][discovery.zen.ping.multicast] [Pitt,  
> Desmond] failed to read requesting data from  
> org.elasticsearch.ElasticSearchIllegalStateException: failed  
> multicastmessage, probably message from previous version at  
> org.elasticsearch.discovery.zen.ping.multicast.MulticastZenPing  
> $Receiver.run(MulticastZenPing.java:406) at  
> java.lang.Thread.run(Thread.java:722)
> 
> What did I do wrong?
> 
> Thanks!

--  
David Pilato  
[http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
Twitter : @dadoonet

---

<div class="post-metadata">

### Author: ![ksquare\_2](https://avatars.discourse-cdn.com/v4/letter/k/9fc348/32.png) [@ksquare\_2](https://discuss.elastic.co/u/ksquare_2)
#### Post date: [March 14, 2012, 7:07am UTC](https://discuss.elastic.co/t/java-client/6972/3 "2012-03-14T07:07:54Z")

</div>

Thanks for your help!

I started elasticsearch with windows and changed my first and second lines  
of code. Now I have

```
public static void main(String[] args) {
    Node node = nodeBuilder().node();
    Client client = node.client (); 
    try {
        IndexResponse response = client
                .prepareIndex("twitter", "tweet", "1")
                .setSource(
                        jsonBuilder()
                                .startObject()
                                .field("user", "kimchy")
                                .field("postDate", new Date())
                                .field("message",
                                        "trying out Elastic Search")
                                .endObject()).execute().actionGet();
    } catch (ElasticSearchException e) {

        e.printStackTrace();
    } catch (IOException e) {

        e.printStackTrace();
    }

    node.close();

}

```

However, when I run it, I got the following error in my java console:

INFO: [Achilles] {elasticsearch/0.16.0}[5864]: started  
Mar 14, 2012 12:00:32 AM org.elasticsearch.common.lucene  
WARNING: Failed to doc writer fields  
java.lang.NoSuchFieldException: rollbackSegmentInfos  
at java.lang.Class.getDeclaredField(Unknown Source)  
at  
org.elasticsearch.common.lucene.IndexWriters.(IndexWriters.java:43)  
at  
org.elasticsearch.index.engine.robin.RobinEngine.newTransactionLogId(RobinEngine.java:1060)  
at  
org.elasticsearch.index.engine.robin.RobinEngine.start(RobinEngine.java:230)  
at  
org.elasticsearch.index.shard.service.InternalIndexShard.performRecoveryPrepareForTranslog(InternalIndexShard.java:480)  
at  
org.elasticsearch.index.gateway.local.LocalIndexShardGateway.recover(LocalIndexShardGateway.java:143)  
at  
org.elasticsearch.index.gateway.IndexShardGatewayService$1.run(IndexShardGatewayService.java:144)  
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)  
at java.lang.Thread.run(Unknown Source)

What does java.lang.NoSuchFieldException: rollbackSegmentInfos mean?

Also in my windows console, I still get the following. What does it mean?

org.elasticsearch.ElasticSearchIllegalStateException: failed multicast  
message, probably message from previous version  
at  
org.elasticsearch.discovery.zen.ping.multicast.MulticastZenPing$Receiver.run(MulticastZenPing.java:406)  
at java.lang.Thread.run(Thread.java:722)  
[2012-03-14 00:00:29,814][WARN][discovery.zen.ping.multicast] [DJ] failed  
to read requesting data  
org.elasticsearch.ElasticSearchIllegalStateException: failed multicast  
message, probably message from previous version  
at  
org.elasticsearch.discovery.zen.ping.multicast.MulticastZenPing$Receiver.run(MulticastZenPing.java:406)  
at java.lang.Thread.run(Thread.java:722)

Thanks!

On Tuesday, March 13, 2012 12:57:59 AM UTC-7, David Pilato wrote:

> There's two way to connect to an ES cluster.
> 
> 1. You start a client node and then ask the node to give you a client.
> 
> 2. You create a simple transport client
> 
> Here you mixes the two ways.
> 
> If you want to use a node, your second line should be :
> 
> Client client = node . client ();
> 
> Did you modify settings for your ES node started with cygwin ?
> 
> BTW, why don't you start it with the windows elasticsearch command line ?
> 
> HTH
> 
> David.
> 
> Le 13 mars 2012 à 08:43, ksquare [ksquaredot@gmail.com](mailto:ksquaredot@gmail.com) a écrit :
> 
> > I am a newbie in Elasticsearch. I am trying to create a Java client  
> > that connects to the Elasticsearch version 0.19.0 started via Cygwin.
> > 
> > Below is my sample code:
> > 
> > ```
> > public static void main(String[] args) { 
> > 
> > Node node = nodeBuilder().client(true).node(); 
> > Client client = new TransportClient() 
> > .addTransportAddress(new 
> > 
> > ```
> 
> InetSocketTransportAddress(
> 
> > ```
> > "127.0.0.1", 9300)); 
> > try { 
> > IndexResponse response = client 
> > .prepareIndex("twitter", 
> > 
> > ```
> 
> "tweet", "1")
> 
> > ```
> > .setSource( 
> > jsonBuilder() 
> > 
> > ```
> 
> .startObject()
> 
> > 
> 
> .field("user", "kimchy")
> 
> > 
> 
> .field("postDate", new Date())
> 
> > 
> 
> .field("message",
> 
> > 
> 
> ```
> "trying out Elastic Search") 
> 
> ```
> 
> > 
> 
> .endObject()).execute().actionGet();
> 
> > ```
> > } catch (ElasticSearchException e) { 
> > 
> > e.printStackTrace(); 
> > } catch (IOException e) { 
> > 
> > e.printStackTrace(); 
> > } 
> > 
> > node.close(); 
> > 
> > } 
> > 
> > ```
> > 
> > However, when I run this test, I get the following error from running  
> > "Node node = nodeBuilder().client(true).node();"
> > 
> > [2012-03-13 00:34:18,712][WARN][discovery.zen.ping.multicast] [Pitt,  
> > Desmond] failed to read requesting data from  
> > org.elasticsearch.ElasticSearchIllegalStateException: failed  
> > multicastmessage, probably message from previous version at  
> > org.elasticsearch.discovery.zen.ping.multicast.MulticastZenPing  
> > $Receiver.run(MulticastZenPing.java:406) at  
> > java.lang.Thread.run(Thread.java:722)
> > 
> > What did I do wrong?
> > 
> > Thanks!
> 
> --  
> David Pilato  
> [http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
> Twitter : @dadoonet

---

<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: [March 14, 2012, 12:39pm UTC](https://discuss.elastic.co/t/java-client/6972/4 "2012-03-14T12:39:20Z")

</div>

Are you sure you are using the correct versions (of elasticsearch with relevant Lucene version)? The rollbackSegmentsInfos message can be ignore...

On Wednesday, March 14, 2012 at 9:07 AM, ksquare wrote:

> Thanks for your help!
> 
> I started elasticsearch with windows and changed my first and second lines of code. Now I have
> 
> ```
> public static void main(String[] args) {
> Node node = nodeBuilder().node();
> Client client = node.client ();  
> try {
> IndexResponse response = client
> .prepareIndex("twitter", "tweet", "1")
> .setSource(
> jsonBuilder()
> .startObject()
> .field("user", "kimchy")
> .field("postDate", new Date())
> .field("message",
> "trying out Elastic Search")
> .endObject()).execute().actionGet();
> } catch (ElasticSearchException e) {
> 
> e.printStackTrace();
> } catch (IOException e) {
> 
> e.printStackTrace();
> }
> 
> node.close();
> 
> }
> 
> ```
> 
> However, when I run it, I got the following error in my java console:
> 
> INFO: [Achilles] {elasticsearch/0.16.0}[5864]: started  
> Mar 14, 2012 12:00:32 AM org.elasticsearch.common.lucene  
> WARNING: Failed to doc writer fields  
> java.lang.NoSuchFieldException: rollbackSegmentInfos  
> at java.lang.Class.getDeclaredField(Unknown Source)  
> at org.elasticsearch.common.lucene.IndexWriters.(IndexWriters.java:43)  
> at org.elasticsearch.index.engine.robin.RobinEngine.newTransactionLogId(RobinEngine.java:1060)  
> at org.elasticsearch.index.engine.robin.RobinEngine.start(RobinEngine.java:230)  
> at org.elasticsearch.index.shard.service.InternalIndexShard.performRecoveryPrepareForTranslog(InternalIndexShard.java:480)  
> at org.elasticsearch.index.gateway.local.LocalIndexShardGateway.recover(LocalIndexShardGateway.java:143)  
> at org.elasticsearch.index.gateway.IndexShardGatewayService$1.run(IndexShardGatewayService.java:144)  
> at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)  
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)  
> at java.lang.Thread.run(Unknown Source)
> 
> What does java.lang.NoSuchFieldException: rollbackSegmentInfos mean?
> 
> Also in my windows console, I still get the following. What does it mean?
> 
> org.elasticsearch.ElasticSearchIllegalStateException: failed multicast message, probably message from previous version  
> at org.elasticsearch.discovery.zen.ping.multicast.MulticastZenPing$Receiver.run(MulticastZenPing.java:406)  
> at java.lang.Thread.run(Thread.java:722)  
> [2012-03-14 00:00:29,814][WARN][discovery.zen.ping.multicast] [DJ] failed to read requesting data  
> org.elasticsearch.ElasticSearchIllegalStateException: failed multicast message, probably message from previous version  
> at org.elasticsearch.discovery.zen.ping.multicast.MulticastZenPing$Receiver.run(MulticastZenPing.java:406)  
> at java.lang.Thread.run(Thread.java:722)
> 
> Thanks!
> 
> On Tuesday, March 13, 2012 12:57:59 AM UTC-7, David Pilato wrote:
> 
> > There's two way to connect to an ES cluster.
> > 
> > 1. You start a client node and then ask the node to give you a client.
> > 
> > 2. You create a simple transport client
> > 
> > Here you mixes the two ways.
> > 
> > If you want to use a node, your second line should be :
> > 
> > Client client = node . client ();
> > 
> > Did you modify settings for your ES node started with cygwin ?
> > 
> > BTW, why don't you start it with the windows elasticsearch command line ?
> > 
> > HTH
> > 
> > David.
> > 
> > Le 13 mars 2012 à 08:43, ksquare \<[ksquaredot@gmail.com](mailto:ksquaredot@gmail.com) ([mailto:ksquaredot@gmail.com](mailto:ksquaredot@gmail.com))\> a écrit :
> > 
> > > I am a newbie in Elasticsearch. I am trying to create a Java client  
> > > that connects to the Elasticsearch version 0.19.0 started via Cygwin.
> > > 
> > > Below is my sample code:
> > > 
> > > ```
> > > public static void main(String[] args) {  
> > > 
> > > Node node = nodeBuilder().client(true).node();  
> > > Client client = new TransportClient()  
> > > .addTransportAddress(new InetSocketTransportAddress(  
> > > "127.0.0.1", 9300));  
> > > try {  
> > > IndexResponse response = client  
> > > .prepareIndex("twitter", "tweet", "1")  
> > > .setSource(  
> > > jsonBuilder()  
> > > .startObject()  
> > > .field("user", "kimchy")  
> > > .field("postDate", new Date())  
> > > .field("message",  
> > > "trying out Elastic Search")  
> > > .endObject()).execute().actionGet();  
> > > } catch (ElasticSearchException e) {  
> > > 
> > > e.printStackTrace();  
> > > } catch (IOException e) {  
> > > 
> > > e.printStackTrace();  
> > > }  
> > > 
> > > node.close();  
> > > 
> > > }  
> > > 
> > > ```
> > > 
> > > However, when I run this test, I get the following error from running  
> > > "Node node = nodeBuilder().client(true).node();"
> > > 
> > > [2012-03-13 00:34:18,712][WARN][discovery.zen.ping.multicast] [Pitt,  
> > > Desmond] failed to read requesting data from  
> > > org.elasticsearch.ElasticSearchIllegalStateException: failed  
> > > multicastmessage, probably message from previous version at  
> > > org.elasticsearch.discovery.zen.ping.multicast.MulticastZenPing  
> > > $Receiver.run(MulticastZenPing.java:406) at  
> > > java.lang.Thread.run(Thread.java:722)
> > > 
> > > What did I do wrong?
> > > 
> > > Thanks!
> > 
> > --  
> > David Pilato  
> > [http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
> > Twitter : @dadoonet

---

<div class="post-metadata">

### Author: ![ksquare\_2](https://avatars.discourse-cdn.com/v4/letter/k/9fc348/32.png) [@ksquare\_2](https://discuss.elastic.co/u/ksquare_2)
#### Post date: [March 14, 2012, 7:54pm UTC](https://discuss.elastic.co/t/java-client/6972/5 "2012-03-14T19:54:37Z")

</div>

I am using elasticsearch 0.19.0, what Lucene dependencies do I need to  
include in my Maven pom.xml file?

Thanks!

On Wednesday, March 14, 2012 5:39:20 AM UTC-7, kimchy wrote:

> Are you sure you are using the correct versions (of elasticsearch with  
> relevant Lucene version)? The rollbackSegmentsInfos message can be  
> ignore...
> 
> On Wednesday, March 14, 2012 at 9:07 AM, ksquare wrote:
> 
> Thanks for your help!
> 
> I started elasticsearch with windows and changed my first and second lines  
> of code. Now I have
> 
> ```
> public static void main(String[] args) {
> Node node = nodeBuilder().node();
> Client client = node.client (); 
> try {
> IndexResponse response = client
> .prepareIndex("twitter", "tweet", "1")
> .setSource(
> jsonBuilder()
> .startObject()
> .field("user", "kimchy")
> .field("postDate", new Date())
> .field("message",
> "trying out Elastic Search")
> .endObject()).execute().actionGet();
> } catch (ElasticSearchException e) {
> 
> e.printStackTrace();
> } catch (IOException e) {
> 
> e.printStackTrace();
> }
> 
> node.close();
> 
> }
> 
> ```
> 
> However, when I run it, I got the following error in my java console:
> 
> INFO: [Achilles] {elasticsearch/0.16.0}[5864]: started  
> Mar 14, 2012 12:00:32 AM org.elasticsearch.common.lucene  
> WARNING: Failed to doc writer fields  
> java.lang.NoSuchFieldException: rollbackSegmentInfos  
> at java.lang.Class.getDeclaredField(Unknown Source)  
> at  
> org.elasticsearch.common.lucene.IndexWriters.(IndexWriters.java:43)  
> at  
> org.elasticsearch.index.engine.robin.RobinEngine.newTransactionLogId(RobinEngine.java:1060)  
> at  
> org.elasticsearch.index.engine.robin.RobinEngine.start(RobinEngine.java:230)  
> at  
> org.elasticsearch.index.shard.service.InternalIndexShard.performRecoveryPrepareForTranslog(InternalIndexShard.java:480)  
> at  
> org.elasticsearch.index.gateway.local.LocalIndexShardGateway.recover(LocalIndexShardGateway.java:143)  
> at  
> org.elasticsearch.index.gateway.IndexShardGatewayService$1.run(IndexShardGatewayService.java:144)  
> at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)  
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)  
> at java.lang.Thread.run(Unknown Source)
> 
> What does java.lang.NoSuchFieldException: rollbackSegmentInfos mean?
> 
> Also in my windows console, I still get the following. What does it mean?
> 
> org.elasticsearch.ElasticSearchIllegalStateException: failed multicast  
> message, probably message from previous version  
> at  
> org.elasticsearch.discovery.zen.ping.multicast.MulticastZenPing$Receiver.run(MulticastZenPing.java:406)  
> at java.lang.Thread.run(Thread.java:722)  
> [2012-03-14 00:00:29,814][WARN][discovery.zen.ping.multicast] [DJ] failed  
> to read requesting data  
> org.elasticsearch.ElasticSearchIllegalStateException: failed multicast  
> message, probably message from previous version  
> at  
> org.elasticsearch.discovery.zen.ping.multicast.MulticastZenPing$Receiver.run(MulticastZenPing.java:406)  
> at java.lang.Thread.run(Thread.java:722)
> 
> Thanks!
> 
> On Tuesday, March 13, 2012 12:57:59 AM UTC-7, David Pilato wrote:
> 
> There's two way to connect to an ES cluster.
> 
> 1. You start a client node and then ask the node to give you a client.
> 
> 2. You create a simple transport client
> 
> Here you mixes the two ways.
> 
> If you want to use a node, your second line should be :
> 
> Client client = node . client ();
> 
> Did you modify settings for your ES node started with cygwin ?
> 
> BTW, why don't you start it with the windows elasticsearch command line ?
> 
> HTH
> 
> David.
> 
> Le 13 mars 2012 à 08:43, ksquare [ksquaredot@gmail.com](mailto:ksquaredot@gmail.com) a écrit :
> 
> > I am a newbie in Elasticsearch. I am trying to create a Java client  
> > that connects to the Elasticsearch version 0.19.0 started via Cygwin.
> > 
> > Below is my sample code:
> > 
> > ```
> > public static void main(String[] args) { 
> > 
> > Node node = nodeBuilder().client(true).node(); 
> > Client client = new TransportClient() 
> > .addTransportAddress(new 
> > 
> > ```
> 
> InetSocketTransportAddress(
> 
> > ```
> > "127.0.0.1", 9300)); 
> > try { 
> > IndexResponse response = client 
> > .prepareIndex("twitter", 
> > 
> > ```
> 
> "tweet", "1")
> 
> > ```
> > .setSource( 
> > jsonBuilder() 
> > 
> > ```
> 
> .startObject()
> 
> > 
> 
> .field("user", "kimchy")
> 
> > 
> 
> .field("postDate", new Date())
> 
> > 
> 
> .field("message",
> 
> > 
> 
> ```
> "trying out Elastic Search") 
> 
> ```
> 
> > 
> 
> .endObject()).execute().actionGet();
> 
> > ```
> > } catch (ElasticSearchException e) { 
> > 
> > e.printStackTrace(); 
> > } catch (IOException e) { 
> > 
> > e.printStackTrace(); 
> > } 
> > 
> > node.close(); 
> > 
> > } 
> > 
> > ```
> > 
> > However, when I run this test, I get the following error from running  
> > "Node node = nodeBuilder().client(true).node();"
> > 
> > [2012-03-13 00:34:18,712][WARN][discovery.zen.ping.multicast] [Pitt,  
> > Desmond] failed to read requesting data from  
> > org.elasticsearch.ElasticSearchIllegalStateException: failed  
> > multicastmessage, probably message from previous version at  
> > org.elasticsearch.discovery.zen.ping.multicast.MulticastZenPing  
> > $Receiver.run(MulticastZenPing.java:406) at  
> > java.lang.Thread.run(Thread.java:722)
> > 
> > What did I do wrong?
> > 
> > Thanks!
> 
> --  
> David Pilato  
> [http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
> Twitter : @dadoonet

---

<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: [March 16, 2012, 5:03pm UTC](https://discuss.elastic.co/t/java-client/6972/6 "2012-03-16T17:03:01Z")

</div>

0.19.0 uses Lucene 3.5, which is part of the elasticsearch pom.xml. Make  
sure you don't have several jar versions (of either elasticsearch or  
Lucene).

On Wed, Mar 14, 2012 at 9:54 PM, ksquare [ksquaredot@gmail.com](mailto:ksquaredot@gmail.com) wrote:

> I am using elasticsearch 0.19.0, what Lucene dependencies do I need to  
> include in my Maven pom.xml file?
> 
> Thanks!
> 
> On Wednesday, March 14, 2012 5:39:20 AM UTC-7, kimchy wrote:
> 
> > Are you sure you are using the correct versions (of elasticsearch with  
> > relevant Lucene version)? The rollbackSegmentsInfos message can be  
> > ignore...
> > 
> > On Wednesday, March 14, 2012 at 9:07 AM, ksquare wrote:
> > 
> > Thanks for your help!
> > 
> > I started elasticsearch with windows and changed my first and second  
> > lines of code. Now I have
> > 
> > ```
> > public static void main(String[] args) {
> > Node node = nodeBuilder().node();
> > Client client = node.client ();
> > try {
> > IndexResponse response = client
> > .prepareIndex("twitter", "tweet", "1")
> > .setSource(
> > jsonBuilder()
> > .startObject()
> > .field("user", "kimchy")
> > .field("postDate", new Date())
> > .field("message",
> > "trying out Elastic Search")
> > .endObject()).execute().**
> > 
> > ```
> > 
> > actionGet();  
> > } catch (ElasticSearchException e) {
> > 
> > ```
> > e.printStackTrace();
> > } catch (IOException e) {
> > 
> > e.printStackTrace();
> > }
> > 
> > node.close();
> > 
> > }
> > 
> > ```
> > 
> > However, when I run it, I got the following error in my java console:
> > 
> > INFO: [Achilles] {elasticsearch/0.16.0}[5864]: started  
> > Mar 14, 2012 12:00:32 AM org.elasticsearch.common.\*\*lucene  
> > WARNING: Failed to doc writer fields  
> > java.lang.\*\*NoSuchFieldException: rollbackSegmentInfos  
> > at java.lang.Class.\*\*getDeclaredField(Unknown Source)  
> > at org.elasticsearch.common.**lucene.IndexWriters.(**  
> > IndexWriters.java:43)  
> > at org.elasticsearch.index. **engine.robin.RobinEngine.**  
> > newTransactionLogId(**RobinEngine.java:1060)  
> > at org.elasticsearch.index.engine.robin.RobinEngine.  
> > start(RobinEngine.java:230)  
> > at org.elasticsearch.index.shard.service.InternalIndexShard.  
> > performRecoveryPrepareForTrans**log(InternalIndexShard.java:\*\*480)  
> > at org.elasticsearch.index.\*\*gateway.local.\*_LocalIndexShardGateway._  
> > \*recover(\*\*LocalIndexShardGateway.java:\*\*143)  
> > at org.elasticsearch.index.\*\*gateway. **IndexShardGatewayService$1.**  
> > run(IndexShardGatewayService.\*\*java:144)  
> > at java.util.concurrent.\*\*ThreadPoolExecutor.runWorker(\*\*Unknown  
> > Source)  
> > at java.util.concurrent.\*\*ThreadPoolExecutor$Worker.run(\*\*Unknown  
> > Source)  
> > at java.lang.Thread.run(Unknown Source)
> > 
> > What does java.lang.\*\*NoSuchFieldException: rollbackSegmentInfos mean?
> > 
> > Also in my windows console, I still get the following. What does it mean?
> > 
> > org.elasticsearch. **ElasticSearchIllegalStateExcep** tion: failed  
> > multicast message, probably message from previous version  
> > at org.elasticsearch.discovery. **zen.ping.multicast.**  
> > MulticastZenPing$Receiver.run(\*\*MulticastZenPing.java:406)  
> > at java.lang.Thread.run(Thread.\*\*java:722)  
> > [2012-03-14 00:00:29,814][WARN][discovery.zen.ping.\*\*multicast] [DJ]  
> > failed to read requesting data  
> > org.elasticsearch. **ElasticSearchIllegalStateExcep** tion: failed  
> > multicast message, probably message from previous version  
> > at org.elasticsearch.discovery. **zen.ping.multicast.**  
> > MulticastZenPing$Receiver.run(\*\*MulticastZenPing.java:406)  
> > at java.lang.Thread.run(Thread.\*\*java:722)
> > 
> > Thanks!
> > 
> > On Tuesday, March 13, 2012 12:57:59 AM UTC-7, David Pilato wrote:
> > 
> > There's two way to connect to an ES cluster.
> > 
> > 1. You start a client node and then ask the node to give you a client.
> > 
> > 2. You create a simple transport client
> > 
> > Here you mixes the two ways.
> > 
> > If you want to use a node, your second line should be :
> > 
> > Client client = node . client ();
> > 
> > Did you modify settings for your ES node started with cygwin ?
> > 
> > BTW, why don't you start it with the windows elasticsearch command line  
> > ?
> > 
> > HTH
> > 
> > David.
> > 
> > Le 13 mars 2012 à 08:43, ksquare [ksquaredot@gmail.com](mailto:ksquaredot@gmail.com) a écrit :
> > 
> > > I am a newbie in Elasticsearch. I am trying to create a Java client  
> > > that connects to the Elasticsearch version 0.19.0 started via Cygwin.
> > > 
> > > Below is my sample code:
> > > 
> > > ```
> > > public static void main(String[] args) {
> > > 
> > > Node node = nodeBuilder().client(true).**node();
> > > Client client = new TransportClient()
> > > .addTransportAddress(new
> > > 
> > > ```
> > 
> > InetSocketTransportAddress(
> > 
> > > ```
> > > "127.0.0.1", 9300));
> > > try {
> > > IndexResponse response = client
> > > .prepareIndex("twitter",
> > > 
> > > ```
> > 
> > "tweet", "1")
> > 
> > > ```
> > > .setSource(
> > > jsonBuilder()
> > > 
> > > ```
> > 
> > .startObject()
> > 
> > > 
> > 
> > .field("user", "kimchy")
> > 
> > > 
> > 
> > .field("postDate", new Date())
> > 
> > > 
> > 
> > .field("message",
> > 
> > > 
> > 
> > ```
> > "trying out Elastic Search")
> > 
> > ```
> > 
> > > 
> > 
> > .endObject()).execute().\*\*actionGet();
> > 
> > > ```
> > > } catch (ElasticSearchException e) {
> > > 
> > > e.printStackTrace();
> > > } catch (IOException e) {
> > > 
> > > e.printStackTrace();
> > > }
> > > 
> > > node.close();
> > > 
> > > }
> > > 
> > > ```
> > > 
> > > However, when I run this test, I get the following error from running  
> > > "Node node = nodeBuilder().client(true).\*\*node();"
> > > 
> > > [2012-03-13 00:34:18,712][WARN][discovery.zen.ping.\*\*multicast]  
> > > [Pitt,  
> > > Desmond] failed to read requesting data from  
> > > org.elasticsearch. **ElasticSearchIllegalStateExcep** tion: failed  
> > > multicastmessage, probably message from previous version at  
> > > org.elasticsearch.discovery.\*\*zen.ping.multicast.\*\*MulticastZenPing  
> > > $Receiver.run(\*\*MulticastZenPing.java:406) at  
> > > java.lang.Thread.run(Thread.\*\*java:722)
> > > 
> > > What did I do wrong?
> > > 
> > > Thanks!
> > 
> > --  
> > David Pilato  
> > [http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
> > Twitter : @dadoonet

---

<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, 3:35am UTC](https://discuss.elastic.co/t/java-client/6972/7 "2017-07-06T03:35:53Z")

</div>


