Client works in plan java, but not in Tomcat

(Dave) #1

I'm working on a elasticsearch client that will run inside Tomcat. I am starting with a simple test. So far, I have the exact same code that works when I run as a java class, but does not work when I execute it in Tomcat.

The code:

Settings settings = ImmutableSettings.settingsBuilder().put("", "test").build();
TransportClient transportClient = new TransportClient(settings);
transportClient = transportClient.addTransportAddress(new InetSocketTransportAddress("localhost", 9300));
SearchRequestBuilder queryBuilder = transportClient.prepareSearch("test-*");
SearchResponse response;
response = queryBuilder.execute().actionGet();

When I run in plan java, I get the results back. When I run in Tomcat, I get a NoNodeAvailableException:

org.elasticsearch.client.transport.NoNodeAvailableException: No node available
at org.elasticsearch.client.transport.TransportClientNodesService.execute(
at org.elasticsearch.action.ActionRequestBuilder.execute(
at org.elasticsearch.action.ActionRequestBuilder.execute(

Any idea why the same code doesn't work in Tomcat?

ElasticSearch, Tomcat, and the plan java test all run on the same machine under the same user account, and the firewall is turned off.

I'm using elasticsearch 1.7.1 for both client and server.

(Dave) #2

The problem was my war somehow had two versions of the elasticsearch client in it, and the wrong version was going used.

(system) #3