IntelliJ IDEA is a popular choice for developing Enterprise applications featuring automatic Maven and Maven integration. In this tutorial we will learn how to integrate IntelliJ with WildFly or JBoss EAP.
IntelliJ IDEA assumes that all development, debugging, and testing is done on your computer and then the code is deployed to a production environment. Let’s see how we can integrate it with WildFly
WildFly and IntelliJ Integration
The integration with WildFly requires the Ultimate version of IntelliJ Idea.
You can find it in: Settings > Build, Executions, Deployment -> Application Servers > “+” > JBoss Server.
Then, you will be able to add a Run/ Debug configuration which includes JBoss Server.
Debugging remotely WildFly with IntelliJ Idea
If you don’t have the Ultimate edition of IntelliJ Idea available, you can still start WildFly as a separate process and debug your applications in IntelliJ. You can however debug your WildFly applications with IntelliJ Idea pretty easily.
Remote debugging is a key feature that is necessary to track issues on your server side applications. In order to activate remote debugging on the application server, a set of JVM arguments needs to be enabled at application server startup. You can enable them in the file
standalone.conf which is located in the
bin folder of the application server:
# Sample JPDA settings for remote socket debugging JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n"n
Next, set up one or more break-points into any of your server side classes. Now you can start the application server as usual with:
You will notice that the server log contains the following line, just at the beginning of it:
Listening for transport dt_socket at address: 8787
Next, you need to attach your IDE the Remote Socket started by WildFly on Port 8787. The simplest way to do that is to select Run | Attach to Process. The runnable process of WildFly will be detected, as you can see from the following snapshot:
Now, if you try to access to the source code which contains a breakpoint, the execution will stop and you will be able to manage the standard debugging flow fro the Debugger panel:
After the program has been suspended, you can use the debugger to get the information about the state of the program and how it changes during running.
The debugger provides you with the information about variable values, objects breakdown, the current state of the threads, and so on. It also allows you to test your program in various conditions by throwing exceptions or running arbitrary code right in the middle of the program execution.
While these tools let you examine the program state at a particular instant, the stepping feature gives you the control over step-by-step execution of the program. By combining the tools you can deduce where the bug is coming from and test your program for robustness.