2017-10-12 08:18:44 -04:00
[role="xpack"]
2018-06-06 17:46:20 -04:00
[testenv="basic"]
2017-10-12 08:18:44 -04:00
[[setup-xpack-client]]
== Configuring {xpack} Java Clients
2017-12-01 06:24:26 -05:00
deprecated[7.0.0, The `TransportClient` is deprecated in favour of the {java-rest}/java-rest-high.html[Java High Level REST Client] and will be removed in Elasticsearch 8.0. The {java-rest}/java-rest-high-level-migration.html[migration guide] describes all the steps needed to migrate.]
2017-10-12 09:27:33 -04:00
If you want to use a Java {javaclient}/transport-client.html[transport client] with a
2017-10-12 08:18:44 -04:00
cluster where {xpack} is installed, then you must download and configure the
{xpack} transport client.
. Add the {xpack} transport JAR file to your *CLASSPATH*. You can download the {xpack}
distribution and extract the JAR file manually or you can get it from the
2019-01-07 08:44:12 -05:00
https://artifacts.elastic.co/maven/org/elasticsearch/client/x-pack-transport/{version}/x-pack-transport-{version}.jar[Elasticsearch Maven repository].
2017-10-12 08:18:44 -04:00
As with any dependency, you will also need its transitive dependencies. Refer to the
https://artifacts.elastic.co/maven/org/elasticsearch/client/x-pack-transport/{version}/x-pack-transport-{version}.pom[X-Pack POM file
for your version] when downloading for offline usage.
. If you are using Maven, you need to add the {xpack} JAR file as a dependency in
your project's `pom.xml` file:
+
--
[source,xml]
--------------------------------------------------------------
<project ...>
<repositories>
<!-- add the elasticsearch repo -->
<repository>
<id>elasticsearch-releases</id>
<url>https://artifacts.elastic.co/maven</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
...
</repositories>
...
<dependencies>
<!-- add the x-pack jar as a dependency -->
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>x-pack-transport</artifactId>
<version>{version}</version>
</dependency>
...
</dependencies>
...
</project>
--------------------------------------------------------------
--
. If you are using Gradle, you need to add the {xpack} JAR file as a dependency in
your `build.gradle` file:
+
--
[source,groovy]
--------------------------------------------------------------
repositories {
/* ... Any other repositories ... */
// Add the Elasticsearch Maven Repository
maven {
2019-05-07 06:34:51 -04:00
name "elastic"
2017-10-12 08:18:44 -04:00
url "https://artifacts.elastic.co/maven"
}
}
dependencies {
compile "org.elasticsearch.client:x-pack-transport:{version}"
/* ... */
}
--------------------------------------------------------------
--
. If you are using a repository manager such as https://www.sonatype.com/nexus-repository-oss[Nexus OSS] within your
company, you need to add the repository as per the following screenshot:
+
--
image::security/images/nexus.png["Adding the Elastic repo in Nexus",link="images/nexus.png"]
Then in your project's `pom.xml` if using maven, add the following repositories and dependencies definitions:
[source,xml]
--------------------------------------------------------------
<dependencies>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>x-pack-transport</artifactId>
<version>{version}</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>local-nexus</id>
<name>Elastic Local Nexus</name>
<url>http://0.0.0.0:8081/repository/elasticsearch/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
--------------------------------------------------------------
--
2018-12-19 17:53:37 -05:00
. If you are using {stack} {security-features}, there are more configuration
2019-12-20 13:01:19 -05:00
steps. See {ref}/java-clients.html[Java Client and security].