JAVA学习提高之---- JBOSS远程调试
来源:互联网 发布:url参数部分变成数组 编辑:程序博客网 时间:2024/06/06 15:50
以下内容引自:http://blog.csdn.net/childhooders/archive/2009/02/05/3864253.aspx
大家的应用发布以后,有时候需要直接在服务器上进行远程调试,以下是远程调试Jboss的方法
我们的Eclipse用的是3.2.2,Jboss是4.2.2
1.设定Jboss的启动参数,把Debug端口放开
打开[/jboss-4.2.2.GA/bin/run.conf]文件,把47行的注释放开,如下所示
# Sample JPDA settings for remote socket debuging
JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
2.利用Eclipse进行Debug
首先在Eclipse中一定要有被调试应用的工程,然后打开Eclipse的Debug模式,选择好对应的工程、远程Server的IP,以及端口(8787),直接运行就可以了。当然要确保服务已启动。
本来是准备了几张图说明的,但是在CSDN中贴图太不方便了,大家还是看看以下网页里的内容吧,说得很清楚了!:)
[http://www.eclipsezone.com/eclipse/forums/t53459.html]
文章出处:http://www.diybl.com/course/3_program/java/javajs/200843/108137.html
对于jboss版本是4.0.5的,通过该写run.conf并不能奏效,需要在run.bat文件中作相应的修改。如下:
Windows环境:
找到Windows下的JBoss的启动文件:run.bat,查找8787,可以找到如下一句:
- rem set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y %JAVA_OPTS%
将该注释去掉(即去掉rem),重新用run.bat启动JBoss即可。
Linux环境:
找到Linux环境下的JBoss启动文件:run.sh
为了保留以前的启动配置,我们作以下操作:
# cp run.conf run-debug.conf
# vi run-debug.sh
- #JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
把注释去掉
重新启动JBoss即可
启动之后,JBoss服务器会在8787端口进行侦听。
按照画面所示设置好跟JBoss服务器的连接之后,便可在程序中设置断点,执行画面处理,便会在断点出停住调试了。
Remote Debugging with Eclipse
At 8:22 PM on Nov 1, 2005, Levent Gurses wrote:
How many times trying to fix a server-side Java problem appearedtrivial, but getting to the source of the problem took all the time? Aremote debugger attached to a Java application can shorten thedefect-discovery times significantly and make the process moreenjoyable.
- The Java Debugger
- Debugging WebLogic
- Debugging JBoss
- Debugging Tomcat
- Debugger Verification
- The Eclipse Connection
- References
- System Info
- About the Author
The Java Debugger
The Java Debugger (jdb) is a dynamic, controlled, assignment-baseddebugging tool. It helps find and fix bugs in the Java languageprograms both locally and on the server. To use jdb in a J2EEapplication server you must first launch it with debugging enabled andattach to the server from the debugger through a JPDA port (Defaultport is 1044).
The default JPDA options for J2EE servers are as follows:
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044
The jdb parameters specify the way debugger will operate. For instance transport=dt_socket instructs the JVM that the debugger connections will be made through a socket while the address=1044 parameter informs it that the port number will be 1044. Similarly, if you substitute suspend=y ,the JVM starts in suspended mode and stays suspended until a debuggeris attached to it. This may be helpful if you want to start debuggingas soon as the JVM starts.
Debugging WebLogic
Debugging WebLogic is no different than debugging any other Javaremote application. You need to make sure to launch it with therequired debugging arguments and attach a debugger. In the case ofWebLogic 8.1, you need to add these arguments to the startup script.WebLogic comes with several launch scripts (*.sh and *.cmd) underBEA_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 other 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 you need to change run.bat/run.sh located under JBOSS_HOME/bin.
Linux users should see 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 that you needto change catalina.bat/catalina.sh located under TOMCAT_HOME/bin.
Debugger Verification
Now you can launch your application in debug mode. Just to make surethat the server is listening to port 1044 you can run netstat /a. Youshould see port 1044 in the list of open ports (See Figure 1: List ofopen ports: netstat -a).
Figure 1 List of open ports: netstat -a
The Eclipse Connection
After making sure WebLogic is listening for incoming connections onport 1044, what is left is to tell Eclipse to connect to this port andyou are ready to debug.
- In Eclipse, navigate to Run | Debug (See Figure 2: Create new Remote Java Application configuration in Eclipse ).
- Select Remote Java Application , on the left column. Click New , on the bottom of the same column.
- In the Create configuration screen you'll be prompted to enter some values. Start with a meaningful name. In my case that's WebLogic Instance . For Project, select the Java project that contains the source code you want to debug. Leave Connection Type in default, i.e. Standard (Socket Attach) . For Host , enter localhost. If you want to debug a remote server, enter its hostname or IP address. For port, enter 1044 or the port you defined in your WebLogic startup script.
- Click Apply
- Make sure WebLogic instance is running in debug mode. In the same screen click Debug . Eclipse should automatically take you to the Debug perspective and you should see a stack trace in the Debug view.
- If you are not automatically taken to the Debug perspective, select Window | Open Perspective | Other and then click Debug.
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 first breakpoint (See Figure 3: Breakpoint hit in Eclipse's debugger ).After that, you can use all the various functions that the debugger hasto offer, namely variable assignments, step-into, drop to frame, etc.
Figure 3 Breakpoint hit in Eclipse debugger
- JAVA学习提高之---- JBOSS远程调试
- JAVA基础学习篇----Eclipse进行(JBOSS)远程调试
- JAVA学习提高之---- JBOSS下配置数据源
- JBOSS学习-初识JBOSS
- jboss远程调试设置
- jboss远程调试设置
- Jboss配置远程调试
- jboss 远程调试
- jboss远程调试
- Jboss 远程调试
- Jboss配置远程调试
- Jboss配置远程调试
- Jboss配置远程调试
- JAVA学习提高之----JAVA开源项目之操作csv文件
- JAVA学习提高之:----JAVA常用误区整理
- JAVA学习提高之----JAVA读写Properties文件
- JAVA学习提高之----Java的多种方式读写Properties文件
- JAVA学习提高之---- Java读取文件中含有中文的解决办法
- LINUX和Redhat学习教程下载帖大全[2008.06]
- 修改远程桌面端口
- 要将程序集“X”标记为系统必备,必须对其进行强签名-使用ClickOnce发布软件时碰到的问题之一
- 选择屏幕字段的自动转化为内部形式
- 千兆网卡,双机互连
- JAVA学习提高之---- JBOSS远程调试
- VSS2005配置所碰到的问题
- ASP.NET MVC实例和新RC版本中视图方面的改进
- 陈绮贞的声音
- windows 不用注销切换其它用户访问服务器共享目录
- Toolbar Dock without drop-down menu
- 使用水晶报表碰到“CrystalDecisions. CrystalReports.Engine.ReportDocument”的类型初始值设定项引发异常
- 什么样的人才可能当上领导?
- 写操作系统(一)执着 总述