Client works in plan java, but not in Tomcat

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("cluster.name", "test").build();
TransportClient transportClient = new TransportClient(settings);
transportClient = transportClient.addTransportAddress(new InetSocketTransportAddress("localhost", 9300));
SearchRequestBuilder queryBuilder = transportClient.prepareSearch("test-*");
queryBuilder.setQuery(QueryBuilders.matchAllQuery());
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(TransportClientNodesService.java:202)
at org.elasticsearch.client.transport.support.InternalTransportClient.execute(InternalTransportClient.java:106)
at org.elasticsearch.client.support.AbstractClient.search(AbstractClient.java:210)
at org.elasticsearch.client.transport.TransportClient.search(TransportClient.java:388)
at org.elasticsearch.action.search.SearchRequestBuilder.doExecute(SearchRequestBuilder.java:816)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:62)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:57)

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.

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