# Maven couldn't transfer "elasticsearch-watcher:pom:2.0.0-rc1" due to authorization

**URL:** <https://discuss.elastic.co/t/maven-couldnt-transfer-elasticsearch-watcher-pom-2-0-0-rc1-due-to-authorization/33030>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [October 27, 2015, 1:21am UTC](https://discuss.elastic.co/t/maven-couldnt-transfer-elasticsearch-watcher-pom-2-0-0-rc1-due-to-authorization/33030 "2015-10-27T01:21:07Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Enniu\_51](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/enniu_51/32/5310_2.png) [@Enniu\_51](https://discuss.elastic.co/u/Enniu_51)\
**Post date:** [October 27, 2015, 1:21am UTC](https://discuss.elastic.co/t/maven-couldnt-transfer-elasticsearch-watcher-pom-2-0-0-rc1-due-to-authorization/33030/1 "2015-10-27T01:21:07Z")

</div>

In [official doc](https://www.elastic.co/guide/en/watcher/2.0.0-rc1/api-java.html) of watcher, it claims one should add this maven dependency to `pom.xml` to use watcher plugin:

```
     <dependency>
         <groupId>org.elasticsearch.plugin</groupId>
         <artifactId>elasticsearch-watcher</artifactId>
         <version>2.0.0-rc1</version>
      </dependency>

```

But when I doing this so, `mvn clean install` gives:

```
 Could not transfer artifact org.elasticsearch.plugin:elasticsearch-watcher:pom:2.0.0-rc1 from/to elasticsearch-releases (http://maven.elasticsearch.org/releases): Not authorized

```

Whole message:

> Failed to execute goal on project crawler-elasticsearch: Could not resolve dependencies for project com.enniu.cloud.services:crawler-elasticsearch:jar:1.2-SNAPSHOT: Failed to collect dependencies at org.elasticsearch.plugin:elasticsearch-watcher:jar:2.0.0-rc1: Failed to read artifact descriptor for org.elasticsearch.plugin:elasticsearch-watcher:jar:2.0.0-rc1: Could not transfer artifact org.elasticsearch.plugin:elasticsearch-watcher:pom:2.0.0-rc1 from/to elasticsearch-releases ([http://maven.elasticsearch.org/releases](http://maven.elasticsearch.org/releases)): Not authorized , ReasonPhrase:Unauthorized. -\> [Help 1]

* * *

By the way, we trying to use watcher `2.0.0-rc1` because now we have upgraded our elasticsearch to `2.0.0-rc1 `.

If we can't use `2.0.0-rc1` of watcher, which version should we use with elasticsearch `2.0.0-rc1`?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 27, 2015, 10:05am UTC](https://discuss.elastic.co/t/maven-couldnt-transfer-elasticsearch-watcher-pom-2-0-0-rc1-due-to-authorization/33030/2 "2015-10-27T10:05:25Z")

</div>

Hey,

can you try this and tell me if it works? Looks as if the docs are wrong, but I want to be sure first:

```xml
    <repositories>
        <repository>
            <id>publicesrepo</id>
            <name>publicesrepo</name>
            <url>http://maven.elasticsearch.org/public-releases</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>2.0.0-rc1</version>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch.plugin</groupId>
            <artifactId>shield</artifactId>
            <version>2.0.0-rc1</version>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch.plugin</groupId>
            <artifactId>watcher</artifactId>
            <version>2.0.0-rc1</version>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch.plugin</groupId>
            <artifactId>license</artifactId>
            <version>2.0.0-rc1</version>
        </dependency>
    </dependencies>

```

--Alex

---

<div class="post-metadata">

**Author:** ![Enniu\_51](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/enniu_51/32/5310_2.png) [@Enniu\_51](https://discuss.elastic.co/u/Enniu_51)\
**Post date:** [October 27, 2015, 10:30am UTC](https://discuss.elastic.co/t/maven-couldnt-transfer-elasticsearch-watcher-pom-2-0-0-rc1-due-to-authorization/33030/3 "2015-10-27T10:30:26Z")

</div>

It works. BTW, @warkolm told me watcher 2.0.0-rc1 not available now in elasticsearch IRC.

---

<div class="post-metadata">

**Author:** ![Enniu\_51](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/enniu_51/32/5310_2.png) [@Enniu\_51](https://discuss.elastic.co/u/Enniu_51)\
**Post date:** [October 27, 2015, 10:40am UTC](https://discuss.elastic.co/t/maven-couldnt-transfer-elasticsearch-watcher-pom-2-0-0-rc1-due-to-authorization/33030/4 "2015-10-27T10:40:55Z")

</div>

I get NPE in this line:

```
    DeleteWatchResponse deleteWatchResponse = watcherClient.prepareDeleteWatch(getName(config)).setForce(true).get();

```

stack trace:

```
Exception in thread "main" java.lang.NullPointerException
	at org.elasticsearch.client.transport.support.TransportProxyClient$1.doWithNode(TransportProxyClient.java:58)
	at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:202)
	at org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55)
	at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:272)
	at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:347)
	at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:85)
	at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:59)
	at org.elasticsearch.action.ActionRequestBuilder.get(ActionRequestBuilder.java:67)
	at com.enniu.cloud.services.elasticsearch.WatcherManager.deleteWatch(WatcherManager.java:120)
	at com.enniu.cloud.services.elasticsearch.WatcherManager.lambda$delete$1(WatcherManager.java:105)
	at com.enniu.cloud.services.elasticsearch.WatcherManager$$Lambda$2/1143968486.apply(Unknown Source)
	at com.enniu.cloud.services.elasticsearch.WatcherManager.performOnWatch(WatcherManager.java:114)
	at com.enniu.cloud.services.elasticsearch.WatcherManager.delete(WatcherManager.java:104)
	at com.enniu.cloud.services.elasticsearch.WatcherManager.main(WatcherManager.java:138)

```

partial logs:

```
18:36:42.969 [main] DEBUG org.elasticsearch.common.netty - using gathering [true]
18:36:43.041 [main] DEBUG org.elasticsearch.client.transport - [Persuasion] node_sampler_interval[5s]
18:36:43.081 [main] DEBUG o.e.n.c.socket.nio.SelectorUtil - Using select timeout of 500
18:36:43.081 [main] DEBUG o.e.n.c.socket.nio.SelectorUtil - Epoll-bug workaround enabled = false
18:36:43.146 [main] DEBUG org.elasticsearch.client.transport - [Persuasion] adding address [{#transport#-1}{10.0.40.156}{10.0.40.156:9300}]
18:36:43.352 [main] DEBUG org.elasticsearch.transport.netty - [Persuasion] connected to node [{#transport#-1}{10.0.40.156}{10.0.40.156:9300}]
18:36:43.429 [main] DEBUG org.elasticsearch.transport.netty - [Persuasion] connected to node [{crawler_service_001}{ppqfzmczTPCnu1-b7wOiIA}{127.0.0.1}{10.0.40.156:9300}]
Exception in thread "main" java.lang.NullPointerException
...
```

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 28, 2015, 9:25am UTC](https://discuss.elastic.co/t/maven-couldnt-transfer-elasticsearch-watcher-pom-2-0-0-rc1-due-to-authorization/33030/5 "2015-10-28T09:25:44Z")

</div>

Hey,

this looks as if the client you are using does not load the watcher plugin. Can you show code, where you instantiate the client that you wrap around `WatcherClient`

```java
        Settings settings = Settings.builder().put("plugin.types", WatcherPlugin.class.getName()).build();

        TransportClient client = TransportClient.builder().settings(settings).build();
        client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
        WatcherClient watcherClient = new WatcherClient(client);

```

in addition you can try the above snippet and see if it works.

--Alex

---

<div class="post-metadata">

**Author:** ![Enniu\_51](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/enniu_51/32/5310_2.png) [@Enniu\_51](https://discuss.elastic.co/u/Enniu_51)\
**Post date:** [October 28, 2015, 9:29am UTC](https://discuss.elastic.co/t/maven-couldnt-transfer-elasticsearch-watcher-pom-2-0-0-rc1-due-to-authorization/33030/6 "2015-10-28T09:29:42Z")

</div>

The code to instantiate the `WathcerClient`:

```
    client = TransportClient.builder().settings(
            Settings.settingsBuilder().put("cluster.name", "elasticsearch_dc_001").build()
    ).build()
            .addTransportAddress(
                    new InetSocketTransportAddress(
                            InetAddress.getByName("x.x.x.x"), 9300
                    )
            );
    WatcherClient watcherClient = new WatcherClient(client);
```

---

<div class="post-metadata">

**Author:** ![Enniu\_51](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/enniu_51/32/5310_2.png) [@Enniu\_51](https://discuss.elastic.co/u/Enniu_51)\
**Post date:** [October 28, 2015, 9:34am UTC](https://discuss.elastic.co/t/maven-couldnt-transfer-elasticsearch-watcher-pom-2-0-0-rc1-due-to-authorization/33030/7 "2015-10-28T09:34:16Z")

</div>

> [@spinscale](#):
>
> Settings settings = Settings.builder().put("plugin.types", WatcherPlugin.class.getName()).build();
> 
> ```
> TransportClient client = TransportClient.builder().settings(settings).build();
> client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
> WatcherClient watcherClient = new WatcherClient(client);
> 
> ```

That works! But I think it would be better if that code appears in watcher 2.0.0 official docs.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 28, 2015, 10:18am UTC](https://discuss.elastic.co/t/maven-couldnt-transfer-elasticsearch-watcher-pom-2-0-0-rc1-due-to-authorization/33030/8 "2015-10-28T10:18:44Z")

</div>

absolutely. I'll add it soon. Thanks for your patience!

--Alex

---

<div class="post-metadata">

**Author:** ![felayman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felayman/32/20791_2.png) [@felayman](https://discuss.elastic.co/u/felayman)\
**Post date:** [January 14, 2017, 3:39pm UTC](https://discuss.elastic.co/t/maven-couldnt-transfer-elasticsearch-watcher-pom-2-0-0-rc1-due-to-authorization/33030/9 "2017-01-14T15:39:40Z")

</div>

thanks for your answer，it hepls me work with the shield plugin.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:42pm UTC](https://discuss.elastic.co/t/maven-couldnt-transfer-elasticsearch-watcher-pom-2-0-0-rc1-due-to-authorization/33030/10 "2017-07-06T13:42:04Z")

</div>


