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.name", 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(Class.java:3138)
at java.base/java.lang.Class.getConstructors(Class.java:1944)
at org.elasticsearch.plugins.PluginsService.loadPlugin(PluginsService.java:588)
at org.elasticsearch.plugins.PluginsService.(PluginsService.java:119)
at org.elasticsearch.client.transport.TransportClient.newPluginService(TransportClient.java:111)
at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:136)
at org.elasticsearch.client.transport.TransportClient.(TransportClient.java:296)
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:130)
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:116)
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:106)
at ......main(TransportClientUtil.java:83)
at .....main(TransportClientUtil.java:49)
at...main(TransportClientUtil.java:201)
Caused by: java.lang.ClassNotFoundException: org.elasticsearch.action.GenericAction
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 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.

org.elasticsearch.transport.Netty4Plugin,
org.elasticsearch.index.reindex.ReindexPlugin,
org.elasticsearch.percolator.PercolatorPlugin,
org.elasticsearch.script.mustache.MustachePlugin,
org.elasticsearch.join.ParentJoinPlugin

Thanks you HenningAndersen.

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