# Elastic APM latest Java agent does't not work on Tomcat 7

**URL:** <https://discuss.elastic.co/t/elastic-apm-latest-java-agent-doest-not-work-on-tomcat-7/245112>\
**Category:** APM\
**Tags:** java\
**Created:** [August 16, 2020, 3:31am UTC](https://discuss.elastic.co/t/elastic-apm-latest-java-agent-doest-not-work-on-tomcat-7/245112 "2020-08-16T03:31:59Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![smakers](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@smakers](https://discuss.elastic.co/u/smakers)\
**Post date:** [August 16, 2020, 3:31am UTC](https://discuss.elastic.co/t/elastic-apm-latest-java-agent-doest-not-work-on-tomcat-7/245112/1 "2020-08-16T03:31:59Z")

</div>

Hi

I've followed an elastic document which is to configure agent JAVA in APM. in final steps when tomcat has been restarted then I can see Catalina.out file only shows the below result. unfortunately, my application also not come out.

2020-08-16 11:03:56,213 [main] INFO co.elastic.apm.agent.util.JmxUtils - Found JVM-specific OperatingSystemMXBean interface: com.sun.management.OperatingSystemMXBean  
2020-08-16 11:03:56,404 [main] INFO co.elastic.apm.agent.configuration.StartupInfo - Starting Elastic APM 1.18.0.RC1 as CMS-172-21-95-132 on Java 1.7.0\_79 Runtime version: 1.7.0\_79-b15 VM version: 24.79-b02 (Oracle Corporation) Linux 3.10.0-1127.el7.x86\_64  
2020-08-16 11:04:00,398 [main] INFO co.elastic.apm.agent.impl.ElasticApmTracer - Tracer switched to RUNNING state

**Tomcat version:** Apache Tomcat/7.0.103  
**Elastic APM version:** 7.7  
**APM Agent version:** elastic-apm-agent-1.18.0.RC1.jar

**My setenv.sh file**

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

Anybody has got a clue what is going on here?

Regards,  
Syed

---

<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 16, 2020, 6:54am UTC](https://discuss.elastic.co/t/elastic-apm-latest-java-agent-doest-not-work-on-tomcat-7/245112/2 "2020-08-16T06:54:23Z")

</div>

Hi @smakers and welcome to the forum!

> [@smakers](#):
>
> unfortunately, my application also not come out.

Is the application not running/responding as expected, or is it just not showing up on Kibana?

---

<div class="post-metadata">

**Author:** ![smakers](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@smakers](https://discuss.elastic.co/u/smakers)\
**Post date:** [August 16, 2020, 12:38pm UTC](https://discuss.elastic.co/t/elastic-apm-latest-java-agent-doest-not-work-on-tomcat-7/245112/3 "2020-08-16T12:38:19Z")

</div>

Hi Eyal,

Thanks for the response. My application also not working.. last logs only showing below screenshot.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/3/23fd5891f4c6ddab31b309f744ba3a3941fd1c38.png)

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

but it's working if I remove the APM agent configuration. need your advise.

---

<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 16, 2020, 1:00pm UTC](https://discuss.elastic.co/t/elastic-apm-latest-java-agent-doest-not-work-on-tomcat-7/245112/4 "2020-08-16T13:00:59Z")

</div>

Sorry about that!

Does the Java process just hang when you launch it, or does it exit immediately?

If it hangs, it could be a deadlock. Please create and upload a thread dump for your Tomcat while it hangs. You can list all running Java process using the `jps` cmd line tool. Once you located the pid corresponding your Tomcat process, run `jstack <pid> > /path/to/thread-dump.log` to create a thread dump.

Then, please try adding:

```auto
export CATALINA_OPTS="$CATALINA_OPTS -Delastic.apm.delay_initialization=5000ms"

```

to your config and see if the problem gets resolved.

Thanks.

---

<div class="post-metadata">

**Author:** ![smakers](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@smakers](https://discuss.elastic.co/u/smakers)\
**Post date:** [August 17, 2020, 2:52am UTC](https://discuss.elastic.co/t/elastic-apm-latest-java-agent-doest-not-work-on-tomcat-7/245112/5 "2020-08-17T02:52:22Z")

</div>

i think the process not hung but it's seem application not working due my war application not starting properly.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/5/6/56a1c6d08fa7045b7520cd34b6739e67bf65c9c6.png)

here are below results from JPS cmd.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/5/6/56a1c6d08fa7045b7520cd34b6739e67bf65c9c6.png)

however, after I put the parameter as advised by you. It's working now but data did not capture in APM-server.

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

logs from APM-Server

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

---

<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 17, 2020, 5:19am UTC](https://discuss.elastic.co/t/elastic-apm-latest-java-agent-doest-not-work-on-tomcat-7/245112/6 "2020-08-17T05:19:53Z")

</div>

> [@smakers](#):
>
> i think the process not hung but it's seem application not working due my war application not starting properly.

If you can produce and upload a thread dump as suggested above, that may be very useful to see.

> [@smakers](#):
>
> however, after I put the parameter as advised by you. It's working now but data did not capture in APM-server.

That's because you are using an old Oracle JDBC driver. However, we just added support for Java 1.4 bytecode, so try [this snapshot](https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=co.elastic.apm&a=elastic-apm-agent&v=LATEST) instead.

I can't say why you don't get anything else - could be the same reason.  
Also, make sure your `application_packages` config contains the root package of your application code. If not, you should either remove it or set it right.  
In any case, it's much better to provide full logs than partial screenshots.

> [@smakers](#):
>
> logs from APM-Server

Looks fine - agent is polling for remote configuration every 30 seconds and sending metrics every 30 seconds.

---

<div class="post-metadata">

**Author:** ![smakers](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@smakers](https://discuss.elastic.co/u/smakers)\
**Post date:** [August 19, 2020, 3:18am UTC](https://discuss.elastic.co/t/elastic-apm-latest-java-agent-doest-not-work-on-tomcat-7/245112/7 "2020-08-19T03:18:31Z")

</div>

hi Eyal,

I want to try using new snapshot(.jar) that your shared recently. however, my application unable to start due to below error.

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

---

<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 19, 2020, 6:06am UTC](https://discuss.elastic.co/t/elastic-apm-latest-java-agent-doest-not-work-on-tomcat-7/245112/8 "2020-08-19T06:06:16Z")

</div>

Make sure that the user running the Tomcat has read permissions for the agent jar.

---

<div class="post-metadata">

**Author:** ![smakers](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@smakers](https://discuss.elastic.co/u/smakers)\
**Post date:** [August 19, 2020, 9:00am UTC](https://discuss.elastic.co/t/elastic-apm-latest-java-agent-doest-not-work-on-tomcat-7/245112/9 "2020-08-19T09:00:54Z")

</div>

hi Eyal,

it's look I've no issue to use previous jar version.

refer below screenshot, I've put in same folder with previous jar file.

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

My setting for setenvh.sh

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/5/35dc4817cd88a6a0b9b72c8a90248a503275fa70.png)

if happened, when i try to start tomcat services. logs in catalina.out file.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/e/bef314cb02d0092f19f9b2fdb83c5d3f32fd5d56.png)

---

<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 19, 2020, 9:48am UTC](https://discuss.elastic.co/t/elastic-apm-latest-java-agent-doest-not-work-on-tomcat-7/245112/10 "2020-08-19T09:48:39Z")

</div>

Please share logs or parts of logs instead of screenshots.  
Also, share your entire agent setting - did you add a dependency somewhere to the agent jar?  
The only place you should refer to the agent jar is in the `setenv.sh` script in the `javaagent` setting. If anything else is aware of agent jar - remove them.

---

<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:** [September 9, 2020, 5:49am UTC](https://discuss.elastic.co/t/elastic-apm-latest-java-agent-doest-not-work-on-tomcat-7/245112/11 "2020-09-09T05:49:02Z")

</div>

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