IntelliJ IDEA's Built-in Remote Debugging | Generated by AI

Home PDF

To connect IntelliJ IDEA to the debug port of a WebSphere Liberty Server that you’ve started with server debug default, without using the WebSphere Liberty plugin, you can leverage IntelliJ IDEA’s built-in remote debugging feature. This approach works because WebSphere Liberty, when started in debug mode, exposes a debug port (typically 7777 by default) that any JVM debugger, including IntelliJ IDEA, can attach to. Below are the detailed steps to achieve this:


Step 1: Start the WebSphere Liberty Server in Debug Mode

When you run server debug default (assuming “default” is the name of your server; replace it with your actual server name if different), WebSphere Liberty starts with debugging enabled. By default, this command configures the server to listen for debug connections on port 7777.


Step 2: Confirm the Debug Port

The default debug port for WebSphere Liberty is 7777. However, if this port is in use or has been customized:

For this guide, we’ll assume the default port 7777 unless your setup indicates otherwise.


Step 3: Configure Remote Debugging in IntelliJ IDEA

IntelliJ IDEA’s remote debugging feature allows you to connect to the server’s JVM without needing a specific WebSphere plugin. Here’s how to set it up:

  1. Open Run/Debug Configurations:
    • In IntelliJ IDEA, go to the top menu and select Run > Edit Configurations.
  2. Add a New Remote Debug Configuration:
    • Click the + button (or “Add New Configuration”) in the top-left corner.
    • From the list, select Remote JVM Debug (it might just say “Remote” depending on your IntelliJ version).
  3. Set Configuration Details:
    • Name: Give it a meaningful name, e.g., “WebSphere Liberty Debug.”
    • Host: Set to localhost (assuming the server runs on the same machine as IntelliJ IDEA; use the server’s IP address if it’s remote).
    • Port: Set to 7777 (or the actual debug port if different).
    • Transport: Ensure it’s set to Socket.
    • Debugger Mode: Select Attach (this tells IntelliJ to connect to an already-running JVM).
    • Leave other settings (like “Command line arguments for remote JVM”) as default unless you need specific JVM options.
  4. Save the Configuration:
    • Click Apply and then OK to save.

Step 4: Start Debugging

With the server running in debug mode and the configuration set up:


Step 5: Debug Your Application


Additional Notes


Summary

By starting your WebSphere Liberty Server with server debug default (which enables debugging on port 7777 by default) and configuring a remote debug setup in IntelliJ IDEA, you can connect to the server’s debug port without the WebSphere Liberty plugin. This gives you full debugging capabilities—breakpoints, variable inspection, and step-through execution—directly within IntelliJ IDEA.


Running and debugging WebSphere Liberty applications in IntelliJ IDEA without the dedicated Liberty Tools plugin is achievable by manually setting up the Liberty runtime and configuring IntelliJ IDEA for remote debugging and external tool execution. This approach requires a few manual steps compared to using the integrated plugin, but it provides the necessary functionality to develop and troubleshoot your Liberty applications.

Here’s a breakdown of the process:

1. Obtain and Install WebSphere Liberty Runtime:

Since you don’t have the plugin to manage the runtime for you, you’ll need to download and install the WebSphere Liberty runtime manually. You can obtain the runtime from the official IBM website or through other distribution methods like Maven or Gradle if you’re managing your project with those tools.

Typically, the manual installation involves downloading a ZIP or JAR file and extracting it to a directory on your system. This directory will be your Liberty installation home (<LIBERTY_HOME>).

2. Configure Liberty Server for Debugging:

To debug your application, you need to start the Liberty server with debugging enabled. This is done by adding specific JVM options when the server starts. These options tell the Java Virtual Machine (JVM) to listen for a debugger connection on a specific port.

Locate the jvm.options file in your Liberty server configuration directory (<LIBERTY_HOME>/usr/servers/<your_server_name>/). If this file doesn’t exist, you can create it. Add the following line to the jvm.options file:

-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005

3. Configure IntelliJ IDEA to Run Liberty:

You can use IntelliJ IDEA’s “External Tools” configuration to start your Liberty server from within the IDE.

Now you can start your Liberty server by going to Tools > External Tools and selecting the tool you just configured.

4. Configure IntelliJ IDEA for Remote Debugging:

To debug your application running on the manually started Liberty server, you’ll use IntelliJ IDEA’s “Remote JVM Debug” configuration.

5. Run and Debug:

  1. Start the Liberty server using the “External Tools” configuration you created in IntelliJ IDEA.
  2. Wait for the server to start and indicate that it’s listening for the debugger on the configured port (you should see a message in the server console output).
  3. Set breakpoints in your application code within IntelliJ IDEA.
  4. Go to Run > Debug and select the “Debug Liberty Server” configuration you created.

IntelliJ IDEA will attempt to connect to the running Liberty server on the specified port. Once connected, you can use all of IntelliJ IDEA’s debugging features, such as stepping through code, inspecting variables, and evaluating expressions.

By following these steps, you can effectively run and debug your WebSphere Liberty applications in IntelliJ IDEA without relying on the dedicated Liberty Tools plugin, giving you direct control over the server lifecycle and debugging process.


Back 2025.03.28 Donate