Java Tomcat Glassfish Weblogic远程debug(remote debug)

tomcat


./catalina.sh jpda start

这条命令启动tomcat,它就会监听8000端口,等待调试器的连接。


要注意不能使用 startup.sh脚本。tomcat会使用 JPDA_ADDRESS这个环境变量的值。

比如想监听8017端口:

export  JPDA_ADDRESS=8017

catalina.sh jpda start


Java

For newer JDK :

-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=6006


For JDK 1.3 or earlier :

-Xnoagent-Djava.compiler=NONE -Xdebug-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=6006

For JDK 1.4

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

Please change the port number based on your needs.

Fromjava technotes

From 5.0 onwards the -agentlib:jdwp option is used to load and specify options to the JDWP agent. For releases prior to 5.0, the -Xdebug and -Xrunjdwp options are used (the 5.0 implementation also supports the -Xdebug and -Xrunjdwp options but the newer -agentlib:jdwp option is preferable as the JDWP agent in 5.0 uses the JVM TI interface to the VM rather than the older JVMDI interface)

One more thing to note, fromJVM Tool interface documentation:

JVM TI was introduced at JDK 5.0. JVM TI replaces the Java Virtual Machine Profiler Interface (JVMPI) and the Java Virtual Machine Debug Interface (JVMDI) which, as of JDK 6, are no longer provided.


WebLogic

export debugFlag=true

export DEBUG_PORT=7878

set | grep -i debug

./startWebLogic.sh


Glassfish

asadmin start-domain --debug [domain-name]


Enabling Debugging

When you enable debugging, you enable both local and remote debugging. To start the server in debug mode, use the----debugoption as follows:

asadmin start-domain --debug [domain-name]

You can then attach to the server from the Java Debugger (jdb) at its default Java Platform Debugger Architecture (JPDA) port, which is 9009. For example, for UNIX systems:

jdb -attach 9009

For Windows:

jdb -connect com.sun.jdi.SocketAttach:port=9009

For more information about thejdbdebugger, see the following links:

Java Platform Debugger Architecture - The Java Debugger:http://java.sun.com/javase/technologies/core/toolsapis/jpda/

Java Platform Debugger Architecture - Connecting with JDB:http://java.sun.com/javase/technologies/core/toolsapis/jpda/

GlassFish Server debugging is based on the JPDA. For more information, seeJPDA Options.

You can attach to the GlassFish Server using any JPDA compliant debugger, including that ofNetBeans, Java Studio Enterprise, JBuilder, Eclipse, and so on.

You can enable debugging even when the GlassFish Server is started without the----debugoption. This is useful if you start the GlassFish Server from the Windows Start Menu, or if you want to make sure that debugging is always turned on.

To Set the Server to Automatically Start Up in Debug Mode

Use the Administration Console. Select the JVM Settings component under the relevant configuration.

Check the Debug Enabled box.

To specify a different port (from 9009, the default) to use when attaching the JVM software to a debugger, specifyaddress=port-numberin the Debug Options field.

To add JPDA options, add any desired JPDA debugging options in Debug Options. SeeJPDA Options.

See Also

For details, click the Help button in the Administration Console from the JVM Settings page.

你可能感兴趣的:(Java Tomcat Glassfish Weblogic远程debug(remote debug))