在 Glassfish 中运行的远程调试 Java Web 应用程序 [英] Remote debugging Java web app running in Glassfish

查看:25
本文介绍了在 Glassfish 中运行的远程调试 Java Web 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网络应用程序.它目前部署在 Glassfish 实例中的远程服务器上.是否可以使用 Netbeans 远程连接到服务器并调试应用程序(就像我调试普通的 Java 应用程序一样)?

I have a web application. It is currently deployed on a remote server in a Glassfish instance. Is it possible to remotely connect to the server and debug the application (like I would a normal java application) using Netbeans?

如果有人这样做并且可以提供见解或可以为我提供指南,那就太好了.

If someone has done this and could provide insight or could point me to a guide, that would be great.

我知道 Visual Studio 和 ASP.Net 中存在此功能.我不确定是否有 Java 等价物.

I know this functionality exists with Visual Studio and ASP.Net. I was not sure if there is a java equivalent.

我在网上看到的大多数示例都是简单地在远程机器上运行的应用程序,或者用于调试在本地机器上运行的 Glassfish 应用程序.

Most examples that I have seen online are for applications that are simply running on a remote machine or for debugging a Glassfish application running on the local machine.

推荐答案

是的,这是可能的.

在调试模式下运行 GlassFish 后,转到 NetBeans 中的调试菜单并单击附加调试器...,这会显示附加 对话框.您可能会选择以下内容:

Once you have GlassFish running in debug mode, go to the Debug menu in NetBeans and click on Attach Debugger..., which brings up the Attach dialog. You'll probably go with something like:

调试器:Java 调试器 (JPDA)

Debugger: Java Debugger (JPDA)

连接器:SocketAttach

Connector: SocketAttach

传输:dt_socket

Transport: dt_socket

主机:hostname_or_ip_address

Host: hostname_or_ip_address

端口:9009

超时可以留空.在此对话框中单击确定后,您应该能够将 NetBeans 调试器连接到 GlassFish.

Timeout may be left blank. When you click OK on this dialog, you should be able to connect your NetBeans debugger to GlassFish.

记住:

  1. 远程服务器(以及中间的任何网关)上的防火墙应允许连接到调试器端口(在我的示例中为 9009).
  2. 确保您使用的是匹配的端口号.在 GlassFish 管理控制台中,通常位于:http://localhost:4848
  3. 展开配置.
  4. 扩展 server-config(或您使用的任何一个).
  5. 点击JVM 设置.
  6. 选中调试启用.
  7. 验证调试选项是否包含:
  1. The firewall on your remote server (and any gateways in between) should allow connections to the debugger port (9009 in my example).
  2. Make sure you're using matching port numbers. In the GlassFish admin console, usually at: http://localhost:4848
  3. Expand Configurations.
  4. Expand server-config (or whichever you are using).
  5. Click JVM Settings.
  6. Check Debug to Enabled.
  7. Verify that Debug Options contains:

-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9009

阅读 JPDA 文档以了解其他信息您可以使用的选项.

Read the JPDA docs for other options you can use.

这篇关于在 Glassfish 中运行的远程调试 Java Web 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆