Unable to start TransportClient : RandomizedContext#getRandom

(Elastic Boston) #1

I am unable to start a transport client. My code is -

Settings settings = Settings.builder()
	       .put("client.transport.sniff", true).build();

TransportClient client = new PreBuiltTransportClient(settings)
	     .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));

The error I get is as below. Note I am not running any unit tests, though there may be some unit tests in the classpath. I have checked that none of them have
@RunWith (Parameterized.class)

I think it is dues to some maven dependancies, but I don't know which one - and I have a gigantic pom.xml and lots of associated files. So I don't know what to update!

[2017-05-11T15:01:49,998][INFO ][o.e.p.PluginsService ] [client] no modules loaded
[2017-05-11T15:01:50,003][INFO ][o.e.p.PluginsService ] [client] loaded plugin [org.elasticsearch.index.reindex.ReindexPlugin]
[2017-05-11T15:01:50,003][INFO ][o.e.p.PluginsService ] [client] loaded plugin [org.elasticsearch.percolator.PercolatorPlugin]
[2017-05-11T15:01:50,003][INFO ][o.e.p.PluginsService ] [client] loaded plugin [org.elasticsearch.script.mustache.MustachePlugin]
[2017-05-11T15:01:50,003][INFO ][o.e.p.PluginsService ] [client] loaded plugin [org.elasticsearch.transport.Netty3Plugin]
[2017-05-11T15:01:50,003][INFO ][o.e.p.PluginsService ] [client] loaded plugin [org.elasticsearch.transport.Netty4Plugin]
Exception in thread "main" java.lang.IllegalStateException: running tests but failed to invoke RandomizedContext#getRandom
at org.elasticsearch.common.Randomness.get(Randomness.java:105)
at org.elasticsearch.client.transport.TransportClientNodesService.(TransportClientNodesService.java:96)
at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:187)
at org.elasticsearch.client.transport.TransportClient.(TransportClient.java:258)
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:125)
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:111)
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:101)

(Jason Tedor) #2

That's the problem, you have randomized runner on your class path. You need to use the Maven dependency tree to find out where it is coming from.

(Elastic Boston) #3

I think we need to use the Randomized runner to create a PreBuiltTransportClient?

I have tried using the annotation on my test class as

but this produces threading issues.
(Even if I use annotation)

(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.