Tuesday, September 6, 2011

Remote debugging problem (Tomcat): "Cannot load this JVM TI agent twice, check your java command line for duplicate jdwp options"


 Hi all,

Today I tried to remotely debug the Apache ODE source using Apache Tomcat 7 and Intellij IDEA. If you are interested in remotely debug,  follow this tutorial http://isharapremadasa.blogspot.com/2011/09/how-to-debug-apache-ode-with-apache.html.

Problem:

I tried it in windows 7. But i was unable to halt the Tomcat's the catalina script at ODE deployment. So i tried to set following windows environment variables (given by IDEA, and modified as suspend=y) for JAVA_OPTS using, 

set JAVA_OPTS=%JAVA_OPTS% -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000

and then tried to run catalina script by running,

catalina.bat jpda run

Then I got this;

ERROR: Cannot load this JVM TI agent twice, check your java command line for duplicate jdwp options.
Error occurred during initialization of VM
agent library failed to init: jdwp

Why ? and Solution

Then I googled about this problem and found the error: when i am going to define both JPDA and environment variables at ones, it cause to generate two instance of debugger and that is not possible. By removing one of them will solve the problem.

So I tried it again removing jpda parameter, and finally I was able to halt the catalina script without ODE deployment.


Notes:


JPDA stands for The Java Platform Debugger Architecture. which is a collection of APIs to debug Java code. (see http://en.wikipedia.org/wiki/JPDA )


1 comment:

  1. Hi Hasitha,
    Yes it is. When you set the JAVA_OPTS, the argument 'Xdebug' informs to start jvm and listen for debugging connections. Therefore tomcat should be started with usual catalina.bat run command after that.
    Thanks for writing about this error.

    ReplyDelete