Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remote debugging Java web app running in Glassfish

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.

like image 277
user489041 Avatar asked May 07 '12 15:05

user489041


People also ask

How do I debug a remote app in Visual Studio?

Select Configure remote debugging to configure the firewall and start the remote debugger. When configuration is complete, the Remote Debugger window appears. The remote debugger is now waiting for a connection. Use the server name and port number shown to set the remote connection configuration in Visual Studio.


1 Answers

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:

Debugger: Java Debugger (JPDA)

Connector: SocketAttach

Transport: dt_socket

Host: hostname_or_ip_address

Port: 9009

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.

like image 55
Edward Samson Avatar answered Sep 30 '22 14:09

Edward Samson