I am using the x-pack-transport client for connecting to ES cluster with x-pack installed.
Settings esSettings = Settings.builder().put("cluster.name", EsClusterName)
.put("xpack.security.user", "username:passwrd")
.build();
TransportClient client =
new PreBuiltXPackTransportClient(esSettings)
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(EsHost), 9300));
I am facing this error when I try to run this
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.elasticsearch.client.Client]: Factory method 'client' threw exception; nested exception is ElasticsearchException[Failed to load plugin class [org.elasticsearch.xpack.XPackPlugin]]; nested: ElasticsearchException[No constructor for [class org.elasticsearch.xpack.XPackPlugin]. A plugin class must have either an empty default constructor or a single argument constructor accepting a Settings instance];
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
... 98 common frames omitted
Caused by: org.elasticsearch.ElasticsearchException: Failed to load plugin class [org.elasticsearch.xpack.XPackPlugin]
at org.elasticsearch.plugins.PluginsService.loadPlugin(PluginsService.java:438) ~[elasticsearch-5.6.9.jar:5.6.9]
at org.elasticsearch.plugins.PluginsService.(PluginsService.java:104) ~[elasticsearch-5.6.9.jar:5.6.9]
at org.elasticsearch.client.transport.TransportClient.newPluginService(TransportClient.java:104) ~[elasticsearch-5.6.9.jar:5.6.9]
at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:129) ~[elasticsearch-5.6.9.jar:5.6.9]
at org.elasticsearch.client.transport.TransportClient.(TransportClient.java:268) ~[elasticsearch-5.6.9.jar:5.6.9]
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:133) ~[transport-5.6.9.jar:5.6.9]
at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.(PreBuiltXPackTransportClient.java:58) ~[x-pack-transport-6.1.4.jar:6.1.4]
at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.(PreBuiltXPackTransportClient.java:53) ~[x-pack-transport-6.1.4.jar:6.1.4]
at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.(PreBuiltXPackTransportClient.java:49) ~[x-pack-transport-6.1.4.jar:6.1.4]
at com.optum.voyager.elasticsearch.elasticsearchapi.config.ElasticSeachConfig.client(ElasticSeachConfig.java:54) ~[classes/:na]
at com.optum.voyager.elasticsearch.elasticsearchapi.config.ElasticSeachConfig$$EnhancerBySpringCGLIB$$74dd8423.CGLIB$client$0() ~[classes/:na]
at com.optum.voyager.elasticsearch.elasticsearchapi.config.ElasticSeachConfig$$EnhancerBySpringCGLIB$$74dd8423$$FastClassBySpringCGLIB$$eecb12bb.invoke() ~[classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at com.optum.voyager.elasticsearch.elasticsearchapi.config.ElasticSeachConfig$$EnhancerBySpringCGLIB$$74dd8423.client() ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_152]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_152]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_152]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_152]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
... 99 common frames omitted
Caused by: org.elasticsearch.ElasticsearchException: No constructor for [class org.elasticsearch.xpack.XPackPlugin]. A plugin class must have either an empty default constructor or a single argument constructor accepting a Settings instance
at org.elasticsearch.plugins.PluginsService.loadPlugin(PluginsService.java:432) ~[elasticsearch-5.6.9.jar:5.6.9]
... 118 common frames omitted