Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java remote debugging Tomcat app: Why does the JVM not listen?

I want to remote debug an application running in Tomcat 7. Tomcat is running as a service on a Win2008 server. I added the following to the Java options in the Java Configuration Panel of Tomcat: -Xdebug -Xrunjdwp:transport=dt_socket,address=4711,server=y,suspend=n and opened the firewall on my workstation and the server for this port. But when I try debugging from IntelliJ 9 on my workstation, I get an error message Unable to open debugger port : java.net.ConnectException "Connection timed out: connect". The jvm is the standatd Sun/Oracle 64 bit JVM version 1.6.0_27.

I verified that the command line parameters are in use by accessing ManagementFactory.getRuntimeMXBean().getInputArguments() within the application deployed to Tomcat and logging the result to the log file. I verified via Wireshark on my workstation and on the server that the TCP request on port 4711 is sent from my pc and arriving on the server, but there is is no answer. Running netstat -a on the server does not show a process listening on this port. So I assume somehow Tomcat/JVM does not start the remote debugging.

like image 563
FrankPl Avatar asked Jan 15 '13 13:01

FrankPl


People also ask

How do I start JVM in debug mode?

Enable JVM Debugging Click Java > JVM Settings tab. Under Debug Java Settings, select the Enable Debug checkbox. Provide JVM options as necessary by clicking the New button. If you substitute suspend=y, the JVM starts in suspended mode and stays suspended until a debugger attaches to it.

How does JVM debugging work?

Since in the JVM architecture, the debugging functionality is not found within the JVM itself but is abstracted away into external tools (that are aptly referred to as debuggers), these tools can either reside on the local machine running the JVM being debugged or be run from am external machine.

What is remote JVM debug?

Remote Java Debugging is the process of debugging a Java program or application running on another machine or a server environment.

How do I start Tomcat with remote debugging?

USING JAVA_OPTS OR CATALINA_OPTS With this added to the options, starting the Tomcat service would have remote debugging enabled. export CATALINA_OPTS="-agentlib:jdwp=transport=dt_socket,address=1043,server=y,suspend=n" Start Tomcat like you would normally then do by running the catalina.


1 Answers

You need to put -Xdebug and -Xrunjdwp... on separate lines in the Java panel of the Tomcat Service Configuration Panel.

So having:

-Xdebug -Xrunjdwp:transport=dt_socket,address=4711,server=y,suspend=n

will not work, but:

-Xdebug
-Xrunjdwp:transport=dt_socket,address=4711,server=y,suspend=n

will.

like image 94
Mikkel Løkke Avatar answered Oct 10 '22 03:10

Mikkel Løkke