Got nullpointer exception when using transport client

hello

      Im new to es and tried to implement it in my project and I got

the error as

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

XContentBuilder docBuilder = XContentFactory.jsonBuilder().startObject();
for(String key:map.keySet())
{
docBuilder.field(key,map.get(key) );
}

            docBuilder.endObject();

indexRreqBuild = client.prepareIndex(indexName, indexType).
setConsistencyLevel(WriteConsistencyLevel.DEFAULT).
setSource(docBuilder);

null pointer exception occurs at client.prepareIndex(indexName, indexType).
line

Can you gist the full stack trace?

On Wed, Dec 28, 2011 at 9:21 AM, Simi MA simi.ma@algotree.com wrote:

hello

      Im new to es and tried to implement it in my project and I got

the error as

              TransportClient client = new TransportClient(s);
              client.addTransportAddress(new

InetSocketTransportAddress(
"localhost",
9300)
);
XContentBuilder docBuilder = XContentFactory.jsonBuilder().startObject();
for(String key:map.keySet())
{
docBuilder.field(key,map.get(key) );
}

            docBuilder.endObject();

indexRreqBuild = client.prepareIndex(indexName, indexType).
setConsistencyLevel(WriteConsistencyLevel.DEFAULT).
setSource(docBuilder);

null pointer exception occurs at client.prepareIndex(indexName,
indexType). line

The gist is
https://gist.github.com/27c02d804dc64cf197b3

On Wed, Dec 28, 2011 at 5:36 AM, Shay Banon kimchy@gmail.com wrote:

Can you gist the full stack trace?

On Wed, Dec 28, 2011 at 9:21 AM, Simi MA simi.ma@algotree.com wrote:

hello

      Im new to es and tried to implement it in my project and I got

the error as

              TransportClient client = new TransportClient(s);
              client.addTransportAddress(new

InetSocketTransportAddress(
"localhost",
9300)
);
XContentBuilder docBuilder = XContentFactory.jsonBuilder().startObject();
for(String key:map.keySet())
{
docBuilder.field(key,map.get(key) );
}

            docBuilder.endObject();

indexRreqBuild = client.prepareIndex(indexName, indexType).
setConsistencyLevel(WriteConsistencyLevel.DEFAULT).
setSource(docBuilder);

null pointer exception occurs at client.prepareIndex(indexName,
indexType). line

Hello

I got where the exception is coming from and solved the problem . Thanx
for your reply

On Wed, Dec 28, 2011 at 6:25 AM, Simi MA simi.ma@algotree.com wrote:

The gist is
https://gist.github.com/27c02d804dc64cf197b3

On Wed, Dec 28, 2011 at 5:36 AM, Shay Banon kimchy@gmail.com wrote:

Can you gist the full stack trace?

On Wed, Dec 28, 2011 at 9:21 AM, Simi MA simi.ma@algotree.com wrote:

hello

      Im new to es and tried to implement it in my project and I got

the error as

              TransportClient client = new TransportClient(s);
              client.addTransportAddress(new

InetSocketTransportAddress(
"localhost",
9300)
);
XContentBuilder docBuilder = XContentFactory.jsonBuilder().startObject();
for(String key:map.keySet())
{
docBuilder.field(key,map.get(key) );
}

            docBuilder.endObject();

indexRreqBuild = client.prepareIndex(indexName, indexType).
setConsistencyLevel(WriteConsistencyLevel.DEFAULT).
setSource(docBuilder);

null pointer exception occurs at client.prepareIndex(indexName,
indexType). line