Using graphs in java : cient creation error

Hello,

I'm currently testing the graph api offered by X-pack.
I could toy a bit with it using kibana, and wanted to test using it in my java application

However, I'm stuck at the creation of the PreBuiltXPackTransportClient.

Here's the creation code :

  Settings settings = Settings.builder()
          .put("cluster.name", "mycluster").build();

  TransportClient client = new PreBuiltXPackTransportClient(settings);
  try {
  	client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("myhost"), 9301));
  } catch (UnknownHostException e) {
  	// TODO Auto-generated catch block
  	e.printStackTrace();
  }

I'm getting this chain of errors

Exception in thread "main" ElasticsearchException[Failed to load plugin class [org.elasticsearch.xpack.XPackPlugin]]; nested: InvocationTargetException; nested: ElasticsearchException[failed to initialize a TrustManagerFactory]; nested: IOException[Keystore was tampered with, or password was incorrect]; nested: UnrecoverableKeyException[Password verification failed];
at org.elasticsearch.plugins.PluginsService.loadPlugin(PluginsService.java:434)
at org.elasticsearch.plugins.PluginsService.(PluginsService.java:103)
at org.elasticsearch.client.transport.TransportClient.newPluginService(TransportClient.java:101)
at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:126)
at org.elasticsearch.client.transport.TransportClient.(TransportClient.java:265)
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:130)
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 application.TestGraph.main(TestGraph.java:22)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.elasticsearch.plugins.PluginsService.loadPlugin(PluginsService.java:423)
... 9 more
Caused by: ElasticsearchException[failed to initialize a TrustManagerFactory]; nested: IOException[Keystore was tampered with, or password was incorrect]; nested: UnrecoverableKeyException[Password verification failed];
at org.elasticsearch.xpack.ssl.StoreTrustConfig.createTrustManager(StoreTrustConfig.java:57)
at org.elasticsearch.xpack.ssl.SSLService.createSslContext(SSLService.java:378)
at org.elasticsearch.xpack.ssl.SSLService.loadSSLConfigurations(SSLService.java:401)
at org.elasticsearch.xpack.ssl.SSLService.(SSLService.java:79)
at org.elasticsearch.xpack.XPackPlugin.(XPackPlugin.java:205)
... 14 more
Caused by: java.io.IOException: Keystore was tampered with, or password was incorrect
at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:772)
at sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:55)
at java.security.KeyStore.load(KeyStore.java:1445)
at org.elasticsearch.xpack.ssl.CertUtils.trustManager(CertUtils.java:168)
at org.elasticsearch.xpack.ssl.StoreTrustConfig.createTrustManager(StoreTrustConfig.java:55)
... 18 more
Caused by: java.security.UnrecoverableKeyException: Password verification failed
at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:770)
... 22 more

However, I disabled x-pack security on my cluster.
I do not understant why the client creation fails at a password verification if I do not have any security.

The version I'm using is 5.5.1.

Can anyone help me with any info on what I might be doing wrong?
Thanks.

That error is referring to the password for your truststore.
Is your application running with a system wide truststore defined? E.g. are you setting the javax.net.ssl.trustStore system property?

Hello, and thanks for answering.

Yes, that property is set.

It's set as a VM argument.
And I tried to set it via System.setproperty as well, but still to no avail.

Well then you need to unset it, or also set the password for the truststore as a system property.

If you run X-Pack with a system truststore then it needs the password too.

1 Like

Thanks for the answer, and sorry for the delay.

Yes, I get it, and that solves my problem.
Thanks a lot.

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