Xpack Watcher Java API


I am trying to follow the guide linked below for creating a WatchSource using WatchSourceBuilder following the instructions.


I have setup the Maven repository and through trial and error (looking at github repositories) I have learned that this documentation is not accurate and that i will also need the following jars in my pom.xml file:

> <repositories>
>     <repository>
>       <id>elasticsearch-releases</id>
>       <url>https://artifacts.elastic.co/maven</url>
>       <releases>
>         <enabled>true</enabled>
>       </releases>
>       <snapshots>
>         <enabled>false</enabled>
>       </snapshots>
>     </repository>
>   </repositories>

>       <dependency>
>         <groupId>org.elasticsearch.plugin</groupId>
>         <artifactId>x-pack-core</artifactId>
>         <version>${elasticsearch.version}</version>
>       </dependency>
>       <dependency>
>         <groupId>org.elasticsearch.plugin</groupId>
>         <artifactId>x-pack-watcher</artifactId>
>         <version>${elasticsearch.version}</version>
>       </dependency>

Version i am using is 6.5.4

Following is the error i am receiving:

[ERROR] Failed to execute goal on project : Could not resolve dependencies for project: Failure to find org.elasticsearch.plugin:x-pack-watcher:jar:6.5.4 in http://nexus-dev/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR] After correcting the problems, you can resume the build with the command

Note: My company does have the premium license

Hi Aparna,

From that doc, it looks like you need the transport dependency:


You tried that and it didn't work?

Hi Scott,

I have tried that and it does not solve the problem.

What i have pinpointed to is that we require this jar:


And I do not see the jar in the maven repository: https://mvnrepository.com/artifact/org.elasticsearch.plugin

Thank you,



Two things:

  1. Without a license, you won't have the Watcher/Alerting plugin within Elasticsearch with which your code can interact. Watcher is a commercial feature. Are you building this for use with clusters that have a license?
  2. Since 5.0, the WatcherClient class is packaged in the x-pack-transport artifact hosted on Elastic's maven repo as described in the Configuring X-Pack Java Clients documentation. In other words, it's not in Maven central.

Ok, a third thing: the transport client is deprecated and will not support the next major version of Elasticsearch (8.0). Moving the the high-level REST client is recommended...it also comes packaged with the Watcher classes. We have a migration guide to help with the migration :slight_smile:

Hi Mike,

Thanks for the reply.

  1. Yes we have the license. Yes we are building this for a cluster that has a license.
  2. We actually did migrate to high-level REST client and it does have an ability to invoke POST/DELETE options but i am specifically looking to build the objects via java code. For that i was following this guide: https://www.elastic.co/guide/en/elastic-stack-overview/6.5/api-java.html


Gotcha, and apologies for reading your previous note as saying, "My company does not have a premium license"

First, we no longer build the x-pack-watcher artifact, which is why you're not finding it for v6.5.4. It's been replaced by x-pack-core.

However, there might be an issue with your specific version. See this GitHub issue detailing an bug with the x-pack-core Maven artifact. The fix was made in 6.6.1, so you'll likely need to bump up to that version, I'm afraid.

You can see all the watcher-related code in 6.6.1 here

should mention that you can verify that the watcher classes are all in that x-pack-core artifact by downloading it from our maven repo and grepping the contents:

jar -tf x-pack-core-6.6.1.jar | grep -i watch

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