如何使用 weblogic 服务器在 eclips 中调试 java web 应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26104666/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to debug java web application in eclips with weblogic server
提问by user2881224
I have java application with Eclipse IDE and WebLogic 11g server. Is it possible to debug application remotely? if yes how?
我有带有 Eclipse IDE 和 WebLogic 11g 服务器的 Java 应用程序。是否可以远程调试应用程序?如果是,如何?
回答by aryn.galadar
First, make sure you enable remote debugging on your startup script for Weblogic:
首先,确保在 Weblogic 的启动脚本上启用远程调试:
-Xdebug -Xrunjdwp:transport=dt_socket,address=9999,server=y,suspend=n
(address is the port number; remember this number)
(地址是端口号;记住这个号码)
Second, you need to set up a new Remote Web Application debug configuration in Eclipse:
其次,您需要在 Eclipse 中设置一个新的远程 Web 应用程序调试配置:
Run -> Debug Configurations...
then create a new Remote Web Application configuration. Make sure you specify your host and port (noted above), and add any source for the web app on the Source tab.
然后创建一个新的远程 Web 应用程序配置。确保指定您的主机和端口(如上所述),并在“源”选项卡上为 Web 应用程序添加任何源。
You should now be able to run that debug configuration to debug a web app in Eclipse on the specified Weblogic server.
您现在应该能够运行该调试配置以在 Eclipse 中在指定的 Weblogic 服务器上调试 Web 应用程序。
回答by Federico Sierra
In startWeblogic.cmd
file, add the following line before ENDLOCAL
line.
在startWeblogic.cmd
文件中,在行之前添加以下ENDLOCAL
行。
set JAVA_OPTIONS=%JAVA_OPTIONS% -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8453,server=y,suspend=n
The Weblogic Server console should display the message:
Weblogic Server 控制台应显示以下消息:
Listening for transport dt_socket at address: 8453
In eclipse follow the instructions below:
在 eclipse 中,请按照以下说明进行操作:
- Select Run > Debug Configurations...from the workbench menu bar (or Debug Configurations...from the drop-down menu on the Debug tool bar button) to show the launch configuration dialog.
- Select the Remote Java Applicationin the list of configuration types on the left.
- Click the Newtoolbar button. A new remote launch configuration is created and three tabs are shown: Connect, Source, and Common.
- In the Projectfield of the Connecttab, type or browse to select the project to use as a reference for the launch (for source lookup). A project does not need to be specified.
- The Connection Typefield of the Connecttab allows you to choose how you will connect to the virtual machine. In most cases, you will be attaching to the vm at a specific location, in which case select Standard (Socket Attach). the rest of these instructions assume you have chosen this option. The Standard (Socket Listen) connection type creates a launch that will listen for incoming connections from a remote VM. You will need to specify a port that the launch will listen at.
- In the Hostfield of the Connect tab, type the IP address or domain name of the host where the Java program is running.If the program is running on the same machine as the workbench, type localhost.
- In the Portfield of the Connect tab, type the port where the remote VM is accepting onnections. Generally, this port is specified when the remote VM is launched.
- The Allow termination of remoteVM flag is a toggle that determines whether the Terminate command is enabled in the debugger. Select this option if you want to be able to terminate the VM to which you are connecting.
- Click Debug. The launch attempts to connect to a VM at the specified address and port, and the result is displayed in the Debug view. If the launcher is unable to connect to a VM at the specified address, an error message appears.
- 从工作台菜单栏中选择运行 > 调试配置...(或从调试工具栏按钮的下拉菜单中选择调试配置...)以显示启动配置对话框。
- 在左侧的配置类型列表中选择远程 Java 应用程序。
- 单击新建工具栏按钮。将创建一个新的远程启动配置并显示三个选项卡:Connect、Source 和 Common。
- 在“连接”选项卡的“项目”字段中,键入或浏览以选择要用作启动参考的项目(用于源查找)。不需要指定项目。
- 连接选项卡的连接类型字段允许您选择连接到虚拟机的方式。在大多数情况下,您将在特定位置附加到虚拟机,在这种情况下,请选择标准(套接字附加)。这些说明的其余部分假定您已选择此选项。标准(套接字侦听)连接类型创建一个启动,它将侦听来自远程 VM 的传入连接。您将需要指定启动将侦听的端口。
- 在连接选项卡的主机字段中,输入运行 Java 程序的主机的 IP 地址或域名。如果程序与工作台在同一台机器上运行,请输入 localhost。
- 在“连接”选项卡的“端口”字段中,键入远程 VM 接受连接的端口。通常,该端口是在启动远程 VM 时指定的。
- 该远程的允许终止VM标志是一个用于确定在调试器终止命令是否被启用切换。如果您希望能够终止要连接的 VM,请选择此选项。
- 单击调试。启动尝试连接到指定地址和端口的 VM,结果显示在 Debug 视图中。如果启动程序无法连接到指定地址的 VM,则会显示错误消息。
Docs:
文档: