Hello Elastic Team,
To enable the security in the elastic, I downloaded the x-pack plugin. Since then the following code is NOT returning the connection.
client = new PreBuiltTransportClient(settings).addTransportAddress(
new InetSocketTransportAddress(inetAddress, port));
Updated the code to
client = new PreBuiltXPackTransportClient(
Settings.builder().put("cluster.name", "elasticsearch").build()).addTransportAddress(
new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
Facing run time issue with the latest code
Exception in thread "main" java.lang.NoClassDefFoundError: org/elasticsearch/xpack/XPackPlugin
at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.(PreBuiltXPackTransportClient.java:55)
at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.(PreBuiltXPackTransportClient.java:50)
at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.(PreBuiltXPackTransportClient.java:46)
at com.symitar.padapter.ESHelper.getClient(ESHelper.java:142)
at com.symitar.padapter.ESHelper.main(ESHelper.java:67)
Caused by: java.lang.ClassNotFoundException: org.elasticsearch.xpack.XPackPlugin
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 5 more
Tried to down load the dependency as per the link "https://www.elastic.co/guide/en/x-pack/current/api-java.html"
[ERROR] Failed to execute goal on project my-app: Could not resolve dependencies for project com.mycompany.app:my-app:jar:1.0-SNAPSHOT: Failed to collect dependencies at org.elasticsearch.client:x-pack-transport:jar:5.4.3: Failed to read artifact descriptor for org.elasticsearch.client:x-pack-transport:jar:5.4.3: Could not transfer artifact org.elasticsearch.client:x-pack-transport:pom:5.4.3 from/to elasticsearch-releases (https://artifacts.elastic.co/maven): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project my-app: Could not resolve dependencies for project com.mycompany.app:my-app:jar:1.0-SNAPSHOT: Failed to collect dependencies at org.elasticsearch.client:x-pack-transport:jar:5.4.3
** at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:221)**
** at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies(LifecycleDependencyResolver.java:127)**
Downloading the jar "x-pack-transport-5.4.3.jar" and placing it in the class path has not helped.