Remote Debugging

Having Public IPs on the platform allows for remote debugging, enabling you to troubleshoot your application while it’s running on the platform by linking it with your IDE’s code. Let’s start by exploring the fundamental elements of remote debugging.

How does remote debugging work?

Well, Java has this neat trick up its sleeve called the listener binding mechanism. Here’s the gist:

  • Imagine you’ve got an application that needs some debugging. It basically hooks itself up to a socket, like a phone line, to listen for any debugging instructions.
  • Then, along comes the debugger, which connects itself to that same socket. It’s like they’re chatting through that socket, exchanging instructions and making sure everything runs smoothly.

Create Environment

1. Log in to your platform’s dashboard.

2. Press the Create Environment button to establish a fresh environment.

New Environment

3. Select the specific instances you wish to utilize (such as the Tomcat application server), establish the limit for cloudlets, and activate the external IP. Next, input the name of the environment and proceed to click on the Create button.

Public IP

The environment will be set up in just a minute.

4. Expand the list of environments to see the number of your Public IP.

IP number

Deploy an Application

1. You can submit your Java package to the Deployment manager.

Java package

2. After placing the package onto the platform, proceed to deploy it into the environment you’ve recently established.

Select Environment

Let’s take a simple application as an example, where we start by setting up three variables, namely a, b, and c, one after the other.

Setup variable

Configure Debugging

1. To get started, open up your IDE (i.e. NetBeans), and then go ahead and create a new debugger. You can do this by navigating to the debugging options (Debug project > Attach Debugger).

Create new Debugger

2. Choose the connector type, enter your Public IP address (host), pick the port number you want to listen on and set timeout preferences if needed.

Connect IP

3. Head back to the platform dashboard and hit the Config button for Tomcat.

Config

4. Head over to the variables.conf file and make sure to include two specific settings: -Xdebug and -Xrunjdwp.

The -Xdebug setting prompts the JVM to operate the application in debug mode, while -Xrunjdwp allows you to input debug parameters.


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

Variable.conf file

Note: Make sure that the port number you set in variables.conf matches the one in your debugger.

5. Don’t forget to Save your changes and then Restart a Tomcat.

6. Add a stopping point in your code to try remote debugging, and then start up the new debugger you just made. In this situation, the application should only set up two variables instead of the usual three.

Add a stopping point

Let’s take a peek at the Tomcat logs to make sure that our debugging is running smoothly.

Test debugging running status

Everything seems to be in order; we’ve set up two variables

7. If we adjust the breakpoint to be one row lower, our application will initialize three variables.

Adjust breakpoints

Running debugging

Tip: The guidance provided works perfectly for the Jetty application server.

If GlassFish is your application server, remember to input the -Xdebug and -Xrunjdwp arguments through the admin panel page.

Once you’ve set up the environment, keep an eye out for an email from the platform. It’ll have the necessary credentials for accessing the GlassFish Admin Console. Just use those credentials to log in when you’re ready.

GlassFIsh Admin Console

Head over to gfcluster-config, then click on JVM Settings. Next, navigate to the General tab and select Debug options. From there, you can customize your debug mode and specify the debug parameters as needed.

JVM settings

Head over to the JVM options and include a couple of arguments:


Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5000.

Include arguments

Please make sure to Save any changes you’ve made and then Restart GlassFish.

Hope these instructions help you.