TransportClient in 7.4.2

Hi, I am using elasitcsearch 7.4.2 with openjdk 11. I can't change all the api to REST, I will do little by little. All CURD I have change to REST (working good) but only for search I want to use TransportClient.

The below is my code which return me the Client
private void transportClient(int esPort, String host, String cluster) {
try {
Settings settings = Settings.builder().put("", cluster).put("client.transport.ignore_cluster_name",true).build();
TransportClient transportClient = new PreBuiltTransportClient(settings);
Client esClient = transportClient.addTransportAddress(new TransportAddress(InetAddress.getByName(host), esPort));
} catch (Exception e) {
But I am getting the following exception. But when I use pom.xml I not facing any issue. When I use without pom.xml (but I have downloaded all the required jars) I am facing the following error.
Kindly help me on this

Exception in thread "main" java.lang.NoClassDefFoundError: org/elasticsearch/action/GenericAction
at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredConstructors(
at java.base/java.lang.Class.getConstructors(
at org.elasticsearch.plugins.PluginsService.loadPlugin(
at org.elasticsearch.plugins.PluginsService.(
at org.elasticsearch.client.transport.TransportClient.newPluginService(
at org.elasticsearch.client.transport.TransportClient.buildTemplate(
at org.elasticsearch.client.transport.TransportClient.(
at org.elasticsearch.transport.client.PreBuiltTransportClient.(
at org.elasticsearch.transport.client.PreBuiltTransportClient.(
at org.elasticsearch.transport.client.PreBuiltTransportClient.(
at ......main(
at .....main(
Caused by: java.lang.ClassNotFoundException: org.elasticsearch.action.GenericAction
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(
at java.base/java.lang.ClassLoader.loadClass(
... 14 more

Hi @rajesh_elasticsearch,

GenericAction was removed in 7.0. You must have something referring to it still on your classpath, could be a plugin or some other dependency.

1 Like

Thanks for your replay, let me cross check my project setup.

The following are the plugin which pointing to the old version. At the time of new PreBuiltTransportClient , this are the plugin loading and in my case its point to the old jar.
I have removed the old plugin jars and now its working fine.


Thanks you HenningAndersen.

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