# java.lang.VerifyError with java agent

**URL:** <https://discuss.elastic.co/t/java-lang-verifyerror-with-java-agent/156882>\
**Category:** APM\
**Created:** [November 15, 2018, 1:56pm UTC](https://discuss.elastic.co/t/java-lang-verifyerror-with-java-agent/156882 "2018-11-15T13:56:59Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wolfram\_Haussig](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wolfram_haussig/32/70528_2.png) [@Wolfram\_Haussig](https://discuss.elastic.co/u/Wolfram_Haussig)\
**Post date:** [November 15, 2018, 1:56pm UTC](https://discuss.elastic.co/t/java-lang-verifyerror-with-java-agent/156882/1 "2018-11-15T13:56:59Z")

</div>

Hello,

I am currently playing with Elastic Stack and APM. I have installed ElasticSearch 6.4.3 and APM-Server 6.5.0 without errors.  
On a tomcat 8.0.x I added the following options:  
-javaagent:/home/user/apm-server-6.5.0-linux-x86\_64/elastic-apm-agent-1.0.0.jar  
-Delastic.apm.service\_name=DEV-TOMCAT  
-Delastic.apm.application\_packages=com.myPackage  
-Delastic.apm.server\_urls=http://127.0.0.1:8200"

Without those settings everything is fine but with them the following error occurs:  
org.springframework.web.context.support.XmlWebApplicationContext- Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authutil' defined in ServletContext resource [/WEB-INF/applicationContext-auth.xml]: Initialization of bean failed; nested exception is java.lang.VerifyError: (class: org/apache/commons/dbcp/DelegatingStatement, method: executeQuery signature: (Ljava/lang/String;)Ljava/sql/ResultSet;) Illegal type in constant pool

The application uses Spring 4(no spring boot) and apache commons dbcp 2.2.0.

Any hints what I am doing wrong? Can I not use dbcp when using apm?

Best regards  
Wolfram

---

<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:** [November 15, 2018, 2:55pm UTC](https://discuss.elastic.co/t/java-lang-verifyerror-with-java-agent/156882/2 "2018-11-15T14:55:47Z")

</div>

Hi and thanks for trying out the Java agent!

I'm sorry you are having troubles with it. I have just tested pretty much all dbcp and dbcp2 versions but was not able to reproduce the problem.

> [@Wolfram\_Haussig](#):
>
> org/apache/commons/dbcp/DelegatingStatement

That indicates that you are not using dbcp2 but dbcp because otherwise the class name would be `org/apache/commons/dbcp2/DelegatingStatement` (notice the `dbcp2`). But dbcp does not have a version 2.2.0. Could you recheck that again?

Which exact Java version and OS are you using?

Thanks,  
Felix

---

<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:** [November 15, 2018, 3:23pm UTC](https://discuss.elastic.co/t/java-lang-verifyerror-with-java-agent/156882/3 "2018-11-15T15:23:29Z")

</div>

A link to the exact version you are using on [search.maven.org](http://search.maven.org) would be helpful 🙂

---

<div class="post-metadata">

**Author:** ![Wolfram\_Haussig](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wolfram_haussig/32/70528_2.png) [@Wolfram\_Haussig](https://discuss.elastic.co/u/Wolfram_Haussig)\
**Post date:** [November 16, 2018, 6:24am UTC](https://discuss.elastic.co/t/java-lang-verifyerror-with-java-agent/156882/4 "2018-11-16T06:24:45Z")

</div>

Hello felix,

Thanks for the fast response. We are using Tomcat 8.0.51 running under openJDK 11 on "Red Hat Enterprise Linux Server release 6.10" - might that be the problem? We are currently evaluating running openJDK because of the oracle license change...

And you are right, I looked into the wrong application - the legacy applications are using Spring 4 too but instead of dbcp2 they use [https://search.maven.org/artifact/commons-dbcp/commons-dbcp/1.3/jar](https://search.maven.org/artifact/commons-dbcp/commons-dbcp/1.3/jar)  
Interestingly, the new application using [https://search.maven.org/artifact/org.apache.commons/commons-dbcp2/2.2.0/jar](https://search.maven.org/artifact/org.apache.commons/commons-dbcp2/2.2.0/jar) is running fine.

Best regards  
Wolfram

---

<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:** [November 16, 2018, 7:18am UTC](https://discuss.elastic.co/t/java-lang-verifyerror-with-java-agent/156882/5 "2018-11-16T07:18:49Z")

</div>

Hm, yesterday, I have tried dbcp 1.3 with Open JDK 11. Could you send me the output of `java -version` so that I can see the exact build you are using?

---

<div class="post-metadata">

**Author:** ![Wolfram\_Haussig](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wolfram_haussig/32/70528_2.png) [@Wolfram\_Haussig](https://discuss.elastic.co/u/Wolfram_Haussig)\
**Post date:** [November 16, 2018, 7:20am UTC](https://discuss.elastic.co/t/java-lang-verifyerror-with-java-agent/156882/6 "2018-11-16T07:20:20Z")

</div>

Sure:  
[tomcat@sapc3027 ~]$ java -version  
openjdk version "11" 2018-09-25  
OpenJDK Runtime Environment 18.9 (build 11+28)  
OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)

---

<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:** [November 16, 2018, 7:28am UTC](https://discuss.elastic.co/t/java-lang-verifyerror-with-java-agent/156882/7 "2018-11-16T07:28:50Z")

</div>

Could you try out dbcp 1.4? This version is compiled against Java 1.6 whereas dbcp 1.3 has been compiled against Java 1.4 which Byte Buddy (the bytecode manipulation framework we are using) does not support.

---

<div class="post-metadata">

**Author:** ![Wolfram\_Haussig](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wolfram_haussig/32/70528_2.png) [@Wolfram\_Haussig](https://discuss.elastic.co/u/Wolfram_Haussig)\
**Post date:** [November 16, 2018, 7:32am UTC](https://discuss.elastic.co/t/java-lang-verifyerror-with-java-agent/156882/8 "2018-11-16T07:32:42Z")

</div>

Perfect! That was the problem.

Thank you very much!!

---

<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:** [December 7, 2018, 3:35am UTC](https://discuss.elastic.co/t/java-lang-verifyerror-with-java-agent/156882/9 "2018-12-07T03:35:07Z")

</div>

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