X-Pack authentication

I've installed x-pack into my elasticsearch: curl --user u:p 'localhost:9200/_xpack':

{
  "build" : {
    "hash" : "e016ba5",
    "date" : "2017-01-24T20:17:08.168Z"
  },
  "license" : {
    "uid" : "a5a93479-cdd1-44c0-8669-78a3ae1cbfeb",
    "type" : "trial",
    "mode" : "trial",
    "status" : "active",
    "expiry_date_in_millis" : 1491567639615
  },
  "features" : {
    "graph" : {
      "description" : "Graph Data Exploration for the Elastic Stack",
      "available" : true,
      "enabled" : false
    },
    "monitoring" : {
      "description" : "Monitoring for the Elastic Stack",
      "available" : true,
      "enabled" : false
    },
    "security" : {
      "description" : "Security for the Elastic Stack",
      "available" : true,
      "enabled" : true
    },
    "watcher" : {
      "description" : "Alerting, Notification and Automation for the Elastic Stack",
      "available" : true,
      "enabled" : false
    }
  },
  "tagline" : "You know, for X"
}

This is my code in order to build my client:

Settings settings = Settings.builder()
        .put(ElasticsearchApplicationResources.ELASTICSEARCH_PROPERTY_CLUSTER_NAME, this.configurationResources.getElasticsearchCluserName())
    .put("xpack.security.user", "elastic:changeme")
    .build();
	
    List<InetSocketTransportAddress> addresses = ...;
	
    try {
	 this.elasticsearchClient = new PreBuiltTransportClient(settings)
		.addTransportAddresses(addresses.toArray(new InetSocketTransportAddress[addresses.size()]));
    }catch (Exception e)
    {
	System.out.print(e);
    }

Currently, I'm getting this message:

java.lang.IllegalArgumentException: unknown setting [xpack.security.user] please check that any required plugins are installed, or check the breaking changes documentation for removed settings

Any ideas?

Read this: https://www.elastic.co/guide/en/x-pack/current/java-clients.html

Thanks @dadoonet.

I've already read this documentation. Nevertheless, I keep failing figure out what's wrong into my code...

Could you suggest me what's wrong?

You are not using the right client.

Sorry, I've misread the documentation.

I'd like to ask you for another question. Do I need to import both

compile group: 'org.elasticsearch.client', name: 'transport', version: '5.2.0'
compile group: 'org.elasticsearch.client', name: 'x-pack-transport', version: '5.2.0'

dependencies? Or importing one of them would be enought?

No. The xpack one will bring automatically the other one.

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