# Error while running plugin where I included CXF and JAXRS

**URL:** <https://discuss.elastic.co/t/error-while-running-plugin-where-i-included-cxf-and-jaxrs/162788>\
**Category:** Elasticsearch\
**Created:** [January 3, 2019, 11:16am UTC](https://discuss.elastic.co/t/error-while-running-plugin-where-i-included-cxf-and-jaxrs/162788 "2019-01-03T11:16:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Linc12](https://avatars.discourse-cdn.com/v4/letter/l/a698b9/32.png) [@Linc12](https://discuss.elastic.co/u/Linc12)\
**Post date:** [January 3, 2019, 11:16am UTC](https://discuss.elastic.co/t/error-while-running-plugin-where-i-included-cxf-and-jaxrs/162788/1 "2019-01-03T11:16:42Z")

</div>

Hi,

I have built a plugin for Elastic and I also included CXF and JAXRS so that I could use the `org.apache.cxf.jaxrs.client.WebClient` like this:

```java
try {
    String responseString = AccessController.doPrivileged((PrivilegedAction<String>) ()
    -> {
        Response response = WebClient.create(url).
                accept(MediaType.APPLICATION_JSON).
                type(MediaType.APPLICATION_JSON).
                post(new Gson().toJson(request));
        return response.readEntity(String.class);
    });
 } catch (Exception e) { }

```

now, when plugin is running and I make a request I get the following stack trace:

```auto
[2019-01-03T11:08:11,816][ERROR][o.e.t.n.Netty4Utils] fatal error on the network layer
        at org.elasticsearch.transport.netty4.Netty4Utils.maybeDie(Netty4Utils.java:182)
        at org.elasticsearch.http.netty4.Netty4HttpRequestHandler.exceptionCaught(Netty4HttpRequestHandler.java:176)
        at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:285)
        at io.netty.channel.AbstractChannelHandlerContext.notifyHandlerException(AbstractChannelHandlerContext.java:850)
...

```

```auto
[ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [docker-single-node] fatal error in thread [Thread-4], exiting
java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
        at org.apache.cxf.service.model.EndpointInfo.setAddress(EndpointInfo.java:97) ~[?:?]
        at org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean.createEndpointInfo(AbstractJAXRSFactoryBean.java:150) ~[?:?]
        at org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean.createEndpoint(AbstractJAXRSFactoryBean.java:219) ~[?:?]
        at org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.createWebClient(JAXRSClientFactoryBean.java:220) ~[?:?]
        at org.apache.cxf.jaxrs.client.WebClient.create(WebClient.java:115) ~[?:?]
...

```

```auto
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
        at java.net.URLClassLoader.findClass(URLClassLoader.java:466) ~[?:?]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:566) ~[?:?]
        at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:890) ~[?:?]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:499) ~[?:?]

```

Here are some dependencies I used:

```auto
<dependency>
  <groupId>javax.ws.rs</groupId>
  <artifactId>javax.ws.rs-api</artifactId>
</dependency>
<dependency>
  <groupId>com.fasterxml.jackson.core</groupId>
  <artifactId>jackson-databind</artifactId>
  <exclusions>
    <exclusion>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
    </exclusion>
  </exclusions>
</dependency>
<dependency>
  <groupId>com.fasterxml.jackson.core</groupId>
  <artifactId>jackson-annotations</artifactId>
</dependency>

```

Any idea about the source of the issue?

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![Linc12](https://avatars.discourse-cdn.com/v4/letter/l/a698b9/32.png) [@Linc12](https://discuss.elastic.co/u/Linc12)\
**Post date:** [January 3, 2019, 3:12pm UTC](https://discuss.elastic.co/t/error-while-running-plugin-where-i-included-cxf-and-jaxrs/162788/3 "2019-01-03T15:12:04Z")

</div>

Ok I solved it by adding:

```auto
<dependency>
  <groupId>javax.xml.bind</groupId>
  <artifactId>jaxb-api</artifactId>
  <version>2.2.11</version>
</dependency>
<dependency>
  <groupId>com.sun.xml.bind</groupId>
  <artifactId>jaxb-core</artifactId>
  <version>2.2.11</version>
</dependency>
<dependency>
  <groupId>com.sun.xml.bind</groupId>
  <artifactId>jaxb-impl</artifactId>
  <version>2.2.11</version>
</dependency>
<dependency>
  <groupId>javax.activation</groupId>
  <artifactId>activation</artifactId>
  <version>1.1.1</version>
</dependency>

```

and removing:

```auto
<dependency>
  <groupId>javax.ws.rs</groupId>
  <artifactId>javax.ws.rs-api</artifactId>
</dependency>

```

---

<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:** [January 31, 2019, 3:12pm UTC](https://discuss.elastic.co/t/error-while-running-plugin-where-i-included-cxf-and-jaxrs/162788/4 "2019-01-31T15:12:19Z")

</div>

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