Do you want to learn how to remotely debug WildFly using IntelliJ or Eclipse? then keep reading this turorial!

Debugging a remotely running Java application using Eclipse IDE is an important skill for any developer. In order to activate remote debug in WildFly, you need to apply some Java options. These options are already included (but commented out) in the standalone.conf file. Here's the line:

JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n"
  • JDWP is the communication protocol used to start the debug. The transport can be of type DT_SOCKET for Linux and DT_SHMEM for Windows machines.
  • Address is the client/server connection URL and by default it is 8787.
  • With suspend=y the Java-process will wait until the debugger connects, with suspend=n you will be also able to debug the application servers startup process.
  • The option server=y opens a socket and listens for incoming debugger requests. With server=n the debugged application will try to connect actively to a debugger and run therefore as a client.

That being said, after uncommenting the line, start WildFly as usual:

$ ./standalone.sh

Now let's deploy an application in it, such as the Hello World: HelloWorld JPA application

Remote debug WildFly using IntelliJ Idea

Start IntelliJ and import your Project. Then, let's add a breakpoint in our application:

wildfly remote debug port remote debug intellij eclipse wildfly

Choose from the Menu Run --> Attach to Process:

wildfly remote debug port remote debug intellij eclipse wildfly

Then, test your application. For example:

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"key":"xyz","value":"xyz"}' \
  http://localhost:8080/jpa-basic/rest/action

You will see that the Debugger kicks in, in your IDE:

wildfly remote debug port remote debug intellij eclipse wildfly

Now you can evaluate variables and debug the execution path of your application.

Remote debugging WildFly with Eclipse

To enable debugging in your Eclipse IDE you can add a new Debug Configuration:

wildfly remote debug port remote debug intellij eclipse wildfly

You may want to check this tutorial to learn how to install the JBoss Tools plugin for Eclipse: Configuring Eclipse to use WildFly

0
0
0
s2sdefault