1. Remote debug In jboss + eclpse
Over the last several weeks I've received a few questions about remote debugging with Eclipse. I posted about this on my other blog back in February here but with not enough info for others to follow.
If you go look at that blog entry you will see that I looked into 'in eclipse' debugging but did not find it satisfactory.
So without further ado here is how I use Tomcat, JBoss, and Eclipse to build and debug applications.
Whichever platform you are using (Tomcat or JBoss) you need to start them with the JPDA debugging enabled. For Tomcat this is very easy. In the $CATALINA_HOME/bin directory there is a script catalina.sh. If you provide the arguments 'jpda start' tomcat will startup and listen on port 8000 for a debugger connection.
With JBoss its only slightly more complicated. Basically you need to specify the JAVA_OPTS to have java start up listening for debugger connections. I typically copy the $JBOSS_HOME/bin/run.sh to $JBOSS_HOME/bin/run-debug.sh but you can just as easily setup the JAVA_OPTS environment variable and use the run.sh script.
The value of JAVA_OPTS needs have -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=4142,suspend=n specified.
So this is what is going on with this argument list
- Xdebug == start the jvm and listen for debugging connections
- Xrunjdwp... == the info on how to connect to do remote debugging
- server=y == start in server mode (i.e. wait for connections, don't go out looking to connect
- transport=dt_socked == use sockets, this works (I think) only on unix (I'm on a mac), on Windows you have to use shared memory via the transport=dt_shmem argument instead. I'm fairly sure this works but its been a while since I tried it on Windows. YMMV. here is the official info on the connection arguments
- address=4142 == the port to connect to or the shared mem address to use
- suspend=n == don't wait for a debugger to tell you what to do, go ahead and launch
Once you have JBoss or Tomcat running and listening for debugging connections you are good to go for connecting with Eclipse
The first thing you need to do is create a 'debug launch configuration' by bringing up the launch configuration editor. Figure 1 shows the menu item to invoke to make that happen
When the launch config editor appears select 'Remote Java Application' from the 'Configurations:' selection list on the left hand side then click the 'New' button. Figure 2 shows the defaults that appear for me after hitting the 'New' button.
Since it defaults to the Tomcat port leave the port number set to 8000, if yours is different then change it to 8000. Notice also that you can specify the host to connect to. If you have access to the port and the process is running on another machine then you can debug the process remotely. This works out really well for those situations where it works fine in your local env but not in the test env. I usually rename the configuration (it defaults to the name of the project for me) to 'Debug Tomcat' or something like that.
The other options (Source & Common) can be ignored for now. If you have not already launched tomcat in debug mode do so now on the command line with $CATALINA_HOME/bin/catalina.sh jpda start. When its launched go back to the Eclipe launch configuration editor and hit the 'Debug' button. If you are not auto switched to the'Debug' perspective go there now. You should see a 'Debug View' that looks a lot like Figure 3.
Your code should be directly below the Debug View if you have the default layout still in place. If so go there and set a break point in one of your servlets' service methods (or any other code that is being executed in Tomcat, like a struts action or whatever) and then go to the Web browser and tickle the code that you have a break point set in. Notice that Eclipse suspends Tomcat at the breakpoint, comes to the front and lets you debug your program. Everything works just as if you were debugging locally.
Everything works the same within JBoss once you get it started with the debugging turned on. Keep in mind that you must set the port to match (in the above discussion of JAVA_OPTS it is set to 4142). So you need to create a new Debug launch configuration and specify 4142 as the port. Then you can debug your EJBs.
Change:
rem set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y %JAVA_OPTS%
To:
set JAVA_OPTS=-classic -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y %JAVA_OPTS%
分享到:
相关推荐
当遇到"JBoss JTA configuration trouble shooting"的问题时,开发者通常需要深入理解JTA的工作原理以及如何在JBoss应用服务器中正确配置它。以下是对这个主题的详细讲解: 首先,JTA是一个Java标准,定义了API来...
在jboss7\standalone\configuration\standalone.xml文件中找到<subsystem xmlns="urn:jboss:domain:web:1.0" default-virtual-server="default-host">做如下配置 Xml代码 收藏代码 <subsystem xmlns="urn:jboss:...
在IntelliJ IDEA 8中,选择菜单栏中的"Edit Configurations",然后双击出现的菜单,选择"Add New Configuration",并选择"JBoss Server",然后为服务器命名。 三、配置Jboss服务器 在配置Jboss服务器时,需要指定...
Jboss 项目部署文档 Jboss 项目部署文档是指在 Jboss 服务器上部署项目的详细步骤,包括环境变量的配置、项目打包、配置文件的修改、JNDI 的配置等。以下是 Jboss 项目部署文档的详细知识点: 一、环境变量配置 ...
【JBOSS,JBoss安装部署】 JBoss是Red Hat公司开发的一款开源的应用服务器,它基于Java EE(Enterprise Edition)规范,提供了全面的企业级应用程序部署和管理解决方案。本篇文章将详细讲解JBoss的安装和部署过程,...
【JBoss 应用服务器详解】 JBoss 是一个开源的、基于 J2EE(Java 2 Platform, Enterprise Edition)的应用服务器,由全球开发者社区共同维护和开发。它最初以 LGPL 许可协议发布,允许商业应用免费使用。2006年,...
JBoss AS 7.1.0.Final是在Linux环境下运行的一款开源Java应用服务器,由Red Hat公司维护。这个版本发布于2012年,它引入了许多改进和新特性,旨在提供更快的启动速度、更高的性能以及更好的模块化。在这个环境中,...
【标题】:“MyEclipse中配置JBoss” 在IT行业中,MyEclipse是一款深受开发者喜爱的集成开发环境(IDE),尤其对于Java EE项目开发来说,它提供了强大的支持。而JBoss则是一个开源的应用服务器,广泛用于部署和管理...
【JBoss 概述】 JBoss 是一个开源的、基于Java的、全面实现了J2EE规范的应用服务器。它提供了企业级的功能,如EJB(Enterprise JavaBeans)、JMS(Java Message Service)、JTS/JTA(Java Transaction Service / ...
JavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-...
【JBoss EAP 7.2.6 补丁包详解】 JBoss Enterprise Application Platform (EAP) 是 Red Hat 提供的一款开源中间件,用于构建、部署和管理企业级 Java 应用程序。JBoss EAP 7.2.6 版本是一个重要的更新,包含了多个...
jboss配置入门 jboss系统是一种基于Java的应用服务器,具有高性能、可扩展、安全性强等特点。在本文中,我们将对jboss的基本配置进行介绍,包括其文件夹结构、配置文件、负载均衡配置等。 jboss文件夹结构 jboss的...
JBoss是一款著名的开源Java应用服务器,它提供了许多企业级服务,包括事务管理、安全性和集群功能。在开发过程中,为了提高效率,我们通常希望在不中断应用服务的情况下更新部署的应用程序,这就是所谓的“热部署”...
JBoss支持多种认证方式,如JaAS(Java Authentication and Authorization Service),可以通过修改`standalone/configuration/standalone.xml`或`domain/configuration/domain.xml`中的安全域配置进行设定。...
JBOSS配置详解 JBOSS是一种流行的Java应用服务器,具有强大的配置功能。在这篇文章中,我们将详细介绍JBOSS的配置,包括下载和安装、目录结构、配置文件等。 一、下载和安装JBOSS 首先,我们需要下载JBOSS的安装...
JBoss是著名的开源Java应用服务器,它基于Java EE(Enterprise Edition)规范,为开发者提供了全面的中间件服务。4.0.5.GA版本是JBoss的一个稳定版本,发布于2006年,适用于那些需要可靠且成熟的Java应用程序部署的...
3. 配置:编辑`standalone/configuration/standalone.xml`或`domain/configuration/domain.xml`文件,根据实际需求进行服务器配置,如端口设置、数据源配置等。 4. 启动:通过命令行执行`bin/standalone.sh`(Linux/...
- **lib**:存放额外的 JAR 文件,与 `lib` 目录不同的是,这里的 JAR 文件仅针对特定的 server configuration。 - **log**:日志文件存放位置。 - **tmp**:临时文件目录。 #### 四、部署应用程序 1. **准备...
《JBoss开发技术文档》是针对企业级应用服务器JBoss的详细指南,旨在帮助开发者深入理解和熟练运用这一开源Java EE应用服务器。本文档分为两大主要部分:JBoss入门和JBoss的配置,涵盖了从安装、启动到高级特性的...