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

问题描述

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



如果有人已经这样做并且可以提供洞察力或可以指向我一个指导,这将是伟大的。



我知道这个功能存在与Visual Studio和ASP.Net。我不确定是否有Java等价物。



我在网上看到的大多数示例都是针对只在远程计算机上运行或调试Glassfish应用程序的应用程序运行在本地机器上。

解决方案

是的,这是可能的。



在调试模式下运行GlassFish后,请转到NetBeans中的调试菜单,然后单击附加调试器... ,这会调出附加对话框。调试器:Java调试器(JPDA)



blockquote>

连接器:SocketAttach



传输:dt_socket
$ b 主机:hostname_or_ip_address

端口:9009


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



请记住:


  1. 远程服务器上的防火墙(以及中间的任何网关)应允许连接到调试器端口(在本例中为9009)。

  2. 确保您使用的是匹配的端口号。在GlassFish管理控制台中,通常位于:

  3. 展开配置

  4. 展开 server-config (或者您正在使用的服务器) li>点击 JVM设置

  5. 检查调试选项 strong>包含:

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

阅读,您可以使用其他选项。


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.

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

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.

解决方案

Yes, it is possible.

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:

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

Remember:

  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

Read the JPDA docs for other options you can use.

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

08-23 19:25