The Java Debugger
The Java Debugger (JDB) is a dynamic, controlled, assignment-based debugging tool. It helps find and fix bugs in the Java language programs both locally and on the server. To use JDB in a Java application server you must-launch it with debugging-enabled and attach to the server Debugger through a JPDA port (Default port is 1044).
The default JPDA options for Java EE servers are as follows:
-xdebug-xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044
The jdb parameters specify the way debugger would operate. For instance Transport=dt_socket instructs the JVM this debugger connections'll be made through a socket WH Ile the address=1044 parameter informs it that port number would be 1044. Similarly, if you are substitute suspend=y , the JVM starts in suspended mode and stays suspended a until is Attached to it. This is helpful if you are want to start debugging as soon as the JVM starts.
Debugging WebLogic
Debugging WebLogic is no different than debugging any other Java remote application. You are need to make sure to launch it with the required debugging arguments and attach a debugger. In the case of WebLogic 8.1, your need to add this arguments to the startup script. WebLogic comes with several launch scripts (*.sh and *.cmd) under Bea_home/weblogic81/server/bin. Locate Startwsl.cmd and add the following variable debug_opts:
Set debug_opts =-xdebug-xrunjdwp:transport= dt_socket,address=1044,server=y,suspend=n
Next, insert the new variable to the WebLogic startup command, after "%java_home%/bin/java" and preferably before the othe R options. Your startup script should look like:
"%java_home%/bin/java"%debug_opts%%java_vm%%mem_args%%java_options%-dweblogic. Name=%server_name%-dweblogic.management.username=%wls_user%-dweblogic.management.password=%WLS_PW%- Dweblogic.management.server=%admin_url%-dweblogic. productionmodeenabled=%production_mode%-djava.security.policy= "%wl_home%/server/lib/weblogic.policy" WebLogic. Server
Debugging JBoss
Same as WebLogic, except that your need to change run.bat/run.sh located the under.
Linux users should something similar to this:
$ cd/var/jboss4/bin
$ sh./run.sh
======================================================================= = =
JBoss Bootstrap environment
jboss_home:/var/jboss4
java:/usr/java/j2sdk1.4.2_06/bin/java
java _opts:-server-xms128m-xmx128m-dprogram.name=run.sh
debug_opts =-xdebug-xrunjdwp:transport= dt_socket,address =1044,server=y,suspend=n
CLASSPATH:/var/jboss4/bin/run.jar:/usr/java/j2sdk1.4.2_06/lib/tools.jar
===== ====================================================================
Debugging Tomcat
Again, very much similar to WebLogic and JBoss, except this need to change catalina.bat/catalina.sh located under At_home/bin.
Debugger Verification
Now I can launch your application in debug mode. Just to make sure this server is listening to port 1044 you can run netstat/a. You should to the 1044 in the list of open ports (for the Figure 1:list of Open ports:netstat-a).
Figure 1 List of open ports:netstat-a
The Eclipse Connection
After making sure WebLogic are listening for incoming connections on port 1044, what are left are to tell the Eclipse to connect To this port and the are ready to debug. In Eclipse, navigate toRun | Debug(TheFigure 2:create New Remote Java application configuration in Eclipse). SelectRemote Java Application, on the left column. ClickNew, on the bottom of the same column. In theCreate ConfigurationScreen you'll be prompted to enter some values. Start with a meaningful name. In I case, that ' sWebLogic Instance. For project, select the Java project this contains the source code you want to debug. LeaveConnection TypeIn default, i.e.Standard (Socket Attach). ForHost, enter localhost. If you are want to debug a remote server, enter its hostname or IP address. For Port, enter1044or the port you defined in your WebLogic startup script. ClickApplyMake sure WebLogic instance are running in debug mode. In the same screen clickDebug. Eclipse should automatically takeDebugPerspective and you should a stack of trace in theDebugView. If you are are not automatically taken to theDebugPerspective, selectWindow | Open Perspective | OtherAnd then clickDebug.
Figure 2 Create New Remote Java application configuration in Eclipse
<span http://
Eclipse Debug window should automatically pop-up with the stack pointer on your A-breakpoint (= Figure Hit in Eclipse ' s debugger). After this, you can use the various functions the debugger has to offer, namely variable, assignments, Step-into, Drop to frame, etc.
Figure 3 breakpoint hit in Eclipse debugger
References debugging Java applications connecting to a remote VM with the Java remote application Launcher debugging with the Eclipse Platform
System Information Windows 3.0 JDK 1.4.2_03 Eclipse BEA WebLogic 8.1 JBoss 4.0.2 Tomcat 5.0.26
Article turn to: Remote Debugging with Eclipse