# JaxRS Async distrubuted tracing not works

**URL:** <https://discuss.elastic.co/t/jaxrs-async-distrubuted-tracing-not-works/189531>\
**Category:** APM\
**Tags:** java\
**Created:** [July 9, 2019, 11:17am UTC](https://discuss.elastic.co/t/jaxrs-async-distrubuted-tracing-not-works/189531 "2019-07-09T11:17:16Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![suikast42](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suikast42/32/29865_2.png) [@suikast42](https://discuss.elastic.co/u/suikast42)\
**Post date:** [July 9, 2019, 11:17am UTC](https://discuss.elastic.co/t/jaxrs-async-distrubuted-tracing-not-works/189531/1 "2019-07-09T11:17:16Z")

</div>

Have a Simple test scenario SeriveA:method1 -\> SeriveB:method1 -\> SeriveA:method2.

\*\* ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/5/f5a772c311ca026cd72b58c3cf90fc6321fa6c6d.png) \*\*

But if I change the call to ServiceB:method1 to async via

```
client.target("http://localhost:8080/wms/backendapi/serivceB/method1").request().async().get().get();

```

then the trace look like shown below:  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/d/cdb12b1f50336079154bff422a3c569fa4620305.png)

So the trace is not propagated

I am using the latest 7.2.0 Stack and apm java agent 1.7.0

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [July 9, 2019, 12:05pm UTC](https://discuss.elastic.co/t/jaxrs-async-distrubuted-tracing-not-works/189531/2 "2019-07-09T12:05:30Z")

</div>

We don't have dedicated support for JAX-RS client API, I assume the sync calls are traced due to our instrumentation of HttpUrlConnection (I just saw that Jersey is using it).  
Can you verify you are using Jersey, or something else?

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [July 9, 2019, 1:30pm UTC](https://discuss.elastic.co/t/jaxrs-async-distrubuted-tracing-not-works/189531/3 "2019-07-09T13:30:13Z")

</div>

I opened [an issue](https://github.com/elastic/apm-agent-java/issues/713) for that.  
@suikast42 if you could provide details on exactly what you are using, that would be great (eg which servlet container, which JAX-RS client).

---

<div class="post-metadata">

**Author:** ![suikast42](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suikast42/32/29865_2.png) [@suikast42](https://discuss.elastic.co/u/suikast42)\
**Post date:** [July 9, 2019, 1:47pm UTC](https://discuss.elastic.co/t/jaxrs-async-distrubuted-tracing-not-works/189531/4 "2019-07-09T13:47:56Z")

</div>

> [@Eyal\_Koren](#):
>
> @suikast42 if you could provide details on exactly what you are using, that would be great (eg which servlet container, which JAX-RS client).

I am using JavaEE8 on to of Wildfly 16.

The Rest client is the standard javax.ws.rs.client.Client

---

<div class="post-metadata">

**Author:** ![nugusbayevkk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nugusbayevkk/32/126683_2.png) [@nugusbayevkk](https://discuss.elastic.co/u/nugusbayevkk)\
**Post date:** [July 11, 2019, 6:01pm UTC](https://discuss.elastic.co/t/jaxrs-async-distrubuted-tracing-not-works/189531/5 "2019-07-11T18:01:34Z")

</div>

hello @suikast42  
I failed to reproduce this problem:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/4/c4689f100568ce7a0da3cc2d84cad0de01f49169.png)  
I added repositories : [service-a](https://github.com/kananindzya/example-service-a), [service-b](https://github.com/kananindzya/example-service-b), [docker-compose](https://github.com/kananindzya/example-docker-compose-apm) .  
And used next dependencies:

```auto
<dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
            <version>2.25.1</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-common</artifactId>
            <version>2.25.1</version>
        </dependency>

```

---

<div class="post-metadata">

**Author:** ![suikast42](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suikast42/32/29865_2.png) [@suikast42](https://discuss.elastic.co/u/suikast42)\
**Post date:** [July 11, 2019, 6:37pm UTC](https://discuss.elastic.co/t/jaxrs-async-distrubuted-tracing-not-works/189531/6 "2019-07-11T18:37:31Z")

</div>

You are trying that with spring.  
I tested under wildfly with JavaEE 8 stack.

Did that work with spring?

---

<div class="post-metadata">

**Author:** ![nugusbayevkk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nugusbayevkk/32/126683_2.png) [@nugusbayevkk](https://discuss.elastic.co/u/nugusbayevkk)\
**Post date:** [July 11, 2019, 6:59pm UTC](https://discuss.elastic.co/t/jaxrs-async-distrubuted-tracing-not-works/189531/7 "2019-07-11T18:59:37Z")

</div>

Yes, it did.  
I will try to reproduce this on wildfly.

---

<div class="post-metadata">

**Author:** ![nugusbayevkk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nugusbayevkk/32/126683_2.png) [@nugusbayevkk](https://discuss.elastic.co/u/nugusbayevkk)\
**Post date:** [July 15, 2019, 7:02pm UTC](https://discuss.elastic.co/t/jaxrs-async-distrubuted-tracing-not-works/189531/8 "2019-07-15T19:02:50Z")

</div>

Hello @suikast42  
I failed to reproduce your problem again:  
I tested on wildfly 16

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/0/a03f8dc5d2475b05360acdeab655f25281df7b12.png)  
added 2 simple projects and deployed to server:  
[service-b-wildfly](https://github.com/kananindzya/example-service-b-wildfly)  
[service-a-wildfly](https://github.com/kananindzya/example-service-a-wildfly)

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/8/d8a4fc44fcd040f9563ed11fea7c88029cfd3d2a.png)

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/0/d0571333b34ac1a3ddfb58caef871c3f44743b4d.png)

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/7/d700264cc0ae84ec77fdf89e8e08545117266abe.png)

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [July 15, 2019, 7:07pm UTC](https://discuss.elastic.co/t/jaxrs-async-distrubuted-tracing-not-works/189531/9 "2019-07-15T19:07:06Z")

</div>

I think the reason why you can't reproduce it is that WildFly comes with it's own JAX-RS implementation which is likely RestEasy.

---

<div class="post-metadata">

**Author:** ![nugusbayevkk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nugusbayevkk/32/126683_2.png) [@nugusbayevkk](https://discuss.elastic.co/u/nugusbayevkk)\
**Post date:** [July 15, 2019, 7:32pm UTC](https://discuss.elastic.co/t/jaxrs-async-distrubuted-tracing-not-works/189531/10 "2019-07-15T19:32:26Z")

</div>

@felixbarny I replaced dependencies to

```auto
    <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-servlet-initializer</artifactId>
            <version>${resteasy.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-client</artifactId>
            <version>${resteasy.version}</version>
            <scope>provided</scope>
        </dependency>

```

but it didn't helped

> <https://gist.github.com/kananindzya/26b757017e2a23bd5656f3ce82a8d3f8>

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [July 16, 2019, 11:37am UTC](https://discuss.elastic.co/t/jaxrs-async-distrubuted-tracing-not-works/189531/11 "2019-07-16T11:37:01Z")

</div>

@suikast42 can you give a more detailed description on how to reproduce the problem?

---

<div class="post-metadata">

**Author:** ![suikast42](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suikast42/32/29865_2.png) [@suikast42](https://discuss.elastic.co/u/suikast42)\
**Post date:** [July 17, 2019, 8:03am UTC](https://discuss.elastic.co/t/jaxrs-async-distrubuted-tracing-not-works/189531/12 "2019-07-17T08:03:15Z")

</div>

Create a simple war project with only Java dependencies.

Then send a request via `ClientBuilder.newCliient().target("http://localhost:8080/backendapi/serivceB/method1").request().async().get().get()`

---

<div class="post-metadata">

**Author:** ![nugusbayevkk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nugusbayevkk/32/126683_2.png) [@nugusbayevkk](https://discuss.elastic.co/u/nugusbayevkk)\
**Post date:** [July 17, 2019, 1:31pm UTC](https://discuss.elastic.co/t/jaxrs-async-distrubuted-tracing-not-works/189531/13 "2019-07-17T13:31:00Z")

</div>

Hi @suikast42, can you share it?

---

<div class="post-metadata">

**Author:** ![suikast42](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suikast42/32/29865_2.png) [@suikast42](https://discuss.elastic.co/u/suikast42)\
**Post date:** [July 18, 2019, 1:37pm UTC](https://discuss.elastic.co/t/jaxrs-async-distrubuted-tracing-not-works/189531/15 "2019-07-18T13:37:48Z")

</div>

I try to extract the problem in a seperate WF war deployment. As soon as possible in my holiday 😉

---

<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:** [August 8, 2019, 9:37am UTC](https://discuss.elastic.co/t/jaxrs-async-distrubuted-tracing-not-works/189531/16 "2019-08-08T09:37:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [August 8, 2019, 10:41am UTC](https://discuss.elastic.co/t/jaxrs-async-distrubuted-tracing-not-works/189531/17 "2019-08-08T10:41:22Z")

</div>

@suikast42 we were not able to reproduce this problem so far.  
If you can find out which exact JAX-RS client implementation doesn't work for you, this can be very useful.  
Thanks!
