简体   繁体   English

如何在Eclipse中调试Java应用服务器?

[英]How do I Debug Java Application Server in Eclipse?

I am attempting to Debug a simple Java Server Application hosted on localhost on any given port. 我正在尝试调试任何给定端口上的localhost上托管的简单Java Server应用程序。 Within Eclipse I run it in debug mode to wait on an incoming connection. 在Eclipse中,我以调试模式运行它以等待传入连接。 When I run my a browser to retrieve data from the server I get nothing. 当我运行浏览器从服务器检索数据时,我什么也没得到。 If I run the Application outside of Eclipse, everything is fine and my pages are served. 如果我在Eclipse之外运行应用程序,那么一切都很好,并且可以提供我的页面。

Is there anything I need to do in Eclipse to enable ports or anything? 我需要在Eclipse中做任何事情来启用端口吗?

I saw this post: How does Eclipse debug code in an application server? 我看到了这篇文章: Eclipse如何在应用程序服务器中调试代码?

but that is only informational. 但这只是提供信息。 Any help would be great. 任何帮助都会很棒。

To debug applications that run on another JVM or even on another machine, start them with these flags: 要调试在另一个JVM或什至在另一台机器上运行的应用程序,请使用以下标志启动它们:

java -Xdebug -Xnoagent \ 
-Djava.compiler=NONE \ 
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005 

Enter the hostname and port to connect for debugging: 输入主机名和端口以进行调试:

 Run → Debug Configuration... menu

Create a new debug configuration of the Remote Java Application type. 创建一个新的远程Java应用程序类型的调试配置。
This configuration allows you to enter the hostname and port for the connection. 此配置允许您输入连接的主机名和端口。

Eclipse Settings: Eclipse设置:
1.Click the Run Button 1.单击运行按钮
2.Select the Debug Configurations 2.选择调试配置
3.Select the “Remote Java Application” 3.选择“远程Java应用程序”
4.New Configuration 4.新配置
a) Name : GatewayPortalProject a)名称:GatewayPortalProject
b) Project : GatewayPortal-portlet b)项目:GatewayPortal-portlet
c) Connection Type: Socket Attach c)连接类型:插座连接
d) Connection Properties: d)连接属性:
i) localhost ii) 8787 i)本地主机ii)8787

For JBoss: 对于JBoss:

1.Change the /path/toJboss/jboss-eap-6.1/bin/standalone.conf in your vm as follows: Uncomment the following line by removing the #: 1.按如下所示在您的/path/toJboss/jboss-eap-6.1/bin/standalone.conf中更改/path/toJboss/jboss-eap-6.1/bin/standalone.conf :通过删除#取消注释以下行:

JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n"

For Tomcat : 对于Tomcat:

In catalina.bat file : catalina.bat文件中:

Step 1: 第1步:

CATALINA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"

Step 2: 第2步:

JPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n"

Step 3: Run Tomcat from command prompt like below: 步骤3:从命令提示符运行Tomcat,如下所示:

catalina.sh jpda start

Then you need to set breakpoints in the Java classes you desire to debug. 然后,您需要在要调试的Java类中设置断点。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM