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.

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容