# Wildfly 8 transactions/traces not catched

**URL:** <https://discuss.elastic.co/t/wildfly-8-transactions-traces-not-catched/184138>\
**Category:** APM\
**Tags:** java\
**Created:** [June 4, 2019, 9:51am UTC](https://discuss.elastic.co/t/wildfly-8-transactions-traces-not-catched/184138 "2019-06-04T09:51:07Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frintrop](https://avatars.discourse-cdn.com/v4/letter/f/e19adc/32.png) [@Frintrop](https://discuss.elastic.co/u/Frintrop)\
**Post date:** [June 4, 2019, 9:51am UTC](https://discuss.elastic.co/t/wildfly-8-transactions-traces-not-catched/184138/1 "2019-06-04T09:51:07Z")

</div>

**Kibana version** : 6.8

**Elasticsearch version** : 6.8

**APM Server version** : 6.8

**APM Agent language and version** : 1.6.1

**Fresh install or upgraded from other version?** fresh

Hi, i have setup java apm agent in our wildfly 8 ejb application.

I see transactions that i.e. will be created inside wildfly itself like startup or scheduled jobs:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/c/4c7db1e596bc0c282e413943febf2da1211df314.png)

But any transaction started via i.e. http-remoting ( methods called from webapps running in seperate tomcats ) or child transaction are not catched and gathered.

Is there a configuration missing ? Is remote invocation not supported ? Should we debug agent ?

If not support, can we start a transaction/ trace manually ?

---

<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:** [June 4, 2019, 10:46am UTC](https://discuss.elastic.co/t/wildfly-8-transactions-traces-not-catched/184138/2 "2019-06-04T10:46:42Z")

</div>

Hi and thanks for your question 🙂

These links should get you started: [https://www.elastic.co/guide/en/apm/agent/java/current/supported-technologies-details.html](https://www.elastic.co/guide/en/apm/agent/java/current/supported-technologies-details.html)  
[https://www.elastic.co/guide/en/apm/agent/java/current/public-api.html](https://www.elastic.co/guide/en/apm/agent/java/current/public-api.html)

What do you exactly mean with http-remoting? Do you have a link to the GitHub repo handy? Is it this one? [http://jbossremoting.jboss.org/remoting-3.html](http://jbossremoting.jboss.org/remoting-3.html) [https://github.com/jboss-remoting/jboss-remoting](https://github.com/jboss-remoting/jboss-remoting)

Let me know if you have any further questions!

Thanks,  
Felix

---

<div class="post-metadata">

**Author:** ![Frintrop](https://avatars.discourse-cdn.com/v4/letter/f/e19adc/32.png) [@Frintrop](https://discuss.elastic.co/u/Frintrop)\
**Post date:** [June 4, 2019, 11:21am UTC](https://discuss.elastic.co/t/wildfly-8-transactions-traces-not-catched/184138/3 "2019-06-04T11:21:32Z")

</div>

Thx. Felix for answering:

http-remoting is one of the ejb remote invocation methods. You found the newest version. Wildfly 8 is still working with that  
[https://github.com/wildfly/jboss-ejb-client/](https://github.com/wildfly/jboss-ejb-client/)

Look here at method 2  
[https://blog.akquinet.de/2014/09/26/jboss-eap-wildfly-three-ways-to-invoke-remote-ejbs/](https://blog.akquinet.de/2014/09/26/jboss-eap-wildfly-three-ways-to-invoke-remote-ejbs/)

EJB invocation hits normally remote interface of ejb and all of its interceptors.

And of course wildfly 8 looks supported, but maybe only servlet 3.x api ? Wondering why i see pure ejb traces ( see above ) in apm ...

![](https://us1.discourse-cdn.com/elastic/original/2X/f/f464dd1c7c382c015b3fc53eebe1cd1aadffee61.jpg)

![](https://us1.discourse-cdn.com/elastic/original/3X/a/f/afc8b23b577bf5509965d0b54e9660d9153ffec7.jpeg)

---

<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:** [June 4, 2019, 1:12pm UTC](https://discuss.elastic.co/t/wildfly-8-transactions-traces-not-catched/184138/4 "2019-06-04T13:12:39Z")

</div>

Yes, supporting WildFly 8 means in this case that the agent is continuously tested to instrument the Servlet API 3.x on WildFly. I agree that this should be a bit more clear from the supported technologies page.

---

<div class="post-metadata">

**Author:** ![Frintrop](https://avatars.discourse-cdn.com/v4/letter/f/e19adc/32.png) [@Frintrop](https://discuss.elastic.co/u/Frintrop)\
**Post date:** [June 4, 2019, 2:02pm UTC](https://discuss.elastic.co/t/wildfly-8-transactions-traces-not-catched/184138/5 "2019-06-04T14:02:16Z")

</div>

Ok. Many thx.

If we start transaction manually via open api, will agent trace all sql queries and subcalls ?

![](https://us1.discourse-cdn.com/elastic/original/2X/f/f464dd1c7c382c015b3fc53eebe1cd1aadffee61.jpg)

---

<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:** [June 4, 2019, 3:18pm UTC](https://discuss.elastic.co/t/wildfly-8-transactions-traces-not-catched/184138/6 "2019-06-04T15:18:30Z")

</div>

yes!

---

<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:** [June 5, 2019, 5:39am UTC](https://discuss.elastic.co/t/wildfly-8-transactions-traces-not-catched/184138/7 "2019-06-05T05:39:37Z")

</div>

@Frintrop maybe you already realized that, but worth the mention- you can add much more interesting support for you cross-tomcat ejb communication than just creating transactions on the server side. You can manually add capability to do distributed tracing, so that the transactions recorded separately on the client side and on the server side will be correlated into traces, representing actual application flows.  
In order to do that, we have the [`injectTraceHeaders`](https://www.elastic.co/guide/en/apm/agent/java/current/public-api.html#api-transaction-inject-trace-headers) (client side) and [`startTransactionWithRemoteParent`](https://www.elastic.co/guide/en/apm/agent/java/current/public-api.html#api-start-transaction-with-remote-parent-header) (server side) APIs.  
Maybe you can use [`EJBClientInterceptor#handleInvocation`](https://github.com/wildfly/jboss-ejb-client/blob/master/src/main/java/org/jboss/ejb/client/EJBClientInterceptor.java#L52) together with [`EJBClientInvocationContext#getContextData`](https://github.com/wildfly/jboss-ejb-client/blob/master/src/main/java/org/jboss/ejb/client/AbstractInvocationContext.java#L82) in order to achieve that.

---

<div class="post-metadata">

**Author:** ![Frintrop](https://avatars.discourse-cdn.com/v4/letter/f/e19adc/32.png) [@Frintrop](https://discuss.elastic.co/u/Frintrop)\
**Post date:** [June 5, 2019, 8:39pm UTC](https://discuss.elastic.co/t/wildfly-8-transactions-traces-not-catched/184138/8 "2019-06-05T20:39:34Z")

</div>

Many thx. But did somebody try to inject header in ejb client ? It looks not very easy.

Von unterwegs gesendet.

---

<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:** [June 6, 2019, 5:37am UTC](https://discuss.elastic.co/t/wildfly-8-transactions-traces-not-catched/184138/9 "2019-06-06T05:37:19Z")

</div>

I never tried it this way 😊  
From a quick look, those APIs seems fit for the task, but I can't really tell without taking a deeper look and try. Generally speaking, if you have the ability to intercept calls on both sides and access to set/read metadata, you should be able to pull this off.  
If you DO try it out, we will love to hear about it.  
Good luck.

---

<div class="post-metadata">

**Author:** ![Frintrop](https://avatars.discourse-cdn.com/v4/letter/f/e19adc/32.png) [@Frintrop](https://discuss.elastic.co/u/Frintrop)\
**Post date:** [June 7, 2019, 7:45am UTC](https://discuss.elastic.co/t/wildfly-8-transactions-traces-not-catched/184138/10 "2019-06-07T07:45:33Z")

</div>

I will try it and give feedback.

I created an ejb interceptor which works for us now. An idea to better check for noop transactions ? instanceof is not working as NoopTransaction.class or NoopTransaction.INSTANCE will not exposed in eclipse.

```
	@AroundInvoke
	public Object profile(InvocationContext invocationContext) throws Exception
       {
		Object object = null;

		final long startTime = System.nanoTime();

		String target = preInvoke(invocationContext);

		Transaction transaction = ElasticApm.currentTransaction();

		if ("NoopTransaction".equals(transaction.getClass().getSimpleName())) // todo
																				// better
																				// check
																				// for
																				// noop;
		{
			transaction = ElasticApm.startTransaction();
			transaction.setName(target);
			transaction.setType(Transaction.TYPE_REQUEST);

			System.out.println("New apm transaction " + transaction.getId() + " with class " + transaction.getClass().getSimpleName());

			try (final Scope scope = transaction.activate())
			{
				object = invoke(invocationContext, target, startTime);
			}
			catch (Exception e)
			{
				transaction.captureException(e);
				throw e;
			}
			finally
			{
				transaction.end();
			}
		}
		else
		{
			System.out.println("Found apm transaction " + transaction.getId() + " with class " + transaction.getClass().getSimpleName());
			Span parentSpan = ElasticApm.currentSpan();

			Span span = parentSpan.startSpan("request", "subcall", null);
			span.setName(target);
			try (final Scope scope = span.activate())
			{
				object = invoke(invocationContext, target, startTime);
			}
			catch (Exception e)
			{
				span.captureException(e);
				throw e;
			}
			finally
			{
				span.end();
			}
		}

		return object;

	}
```

---

<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:** [June 10, 2019, 9:14am UTC](https://discuss.elastic.co/t/wildfly-8-transactions-traces-not-catched/184138/11 "2019-06-10T09:14:31Z")

</div>

You can check whether `transaction.getId` or `transaction.getTraceId` returns a valid ID (meaning valid transaction) or an empty string (noop transactions).

BTW, since a `Transaction` is a kind of a `Span`, you can replace

```auto
        else
		{
			System.out.println("Found apm transaction " + transaction.getId() + " with class " + transaction.getClass().getSimpleName());
			Span parentSpan = ElasticApm.currentSpan();

			Span span = parentSpan.startSpan("request", "subcall", null);
			...

```

with

```auto
        else
		{
			System.out.println("Found apm transaction " + transaction.getId() + " with class " + transaction.getClass().getSimpleName());
			Span span = transaction.startSpan("request", "subcall", null);
			...

```

---

<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 1, 2019, 5:14am UTC](https://discuss.elastic.co/t/wildfly-8-transactions-traces-not-catched/184138/12 "2019-07-01T05:14:50Z")

</div>

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