1. Debugging the Application Deployed to Payara Server
If you want to debug your application deployed on Payara Server, you may start a server in the debug mode :
1.a) Using NetBeans IDE Plugin :
Adding Payara Server to NetBeans :
Go to Tools → Servers.
Click Add Server.
Select Payara Server and choose a name for the server.
Select the location of the Payara Server.
Once Payara Server is added to NetBeans it can be found under Servers with the configured name. That’s how to add Payara Server to NetBeans.
Debugging the Application :
First, the application run settings need to be configured to use Payara Server. Go to Properties on a project and then the Run section of this window. Now select the Payara Server from Server list.
In the Projects window, navigate to the your project, right click and In the pop-up menu select Debug. The IDE start the Payara server in debug mode and deploys the project.
Now add the breakpoints in the program, trace the program execution step-by-step by evaluating the value of variables and diagnosethe problem.
1.b) Using the Command Line :
Alternatively you may also start the Payara Server in debug mode using the following asadmin command with –debug flag :
After Payara Server starts you may manually attach the debugger to your application in the NetBeans IDE. From the main menu, select Debug→Attach Debugger, enter the port value 9009 and click ok :
2. Debugging the Payara Micro Application
If you want to debug your Payara Micro application, you may start a micro instance in the debug mode :
2.a) Using NetBeans IDE Plugin :
Creating Payara Micro Application :
Simply start up the NetBeans IDE and then Choose File → New Project from the main menu.
On the Choose Project panel, select Maven from Categories, select Payara Micro Application from Projects, and click Next.
On the Name and Location panel, enter SampleMicro as the project name, set the Project Location, set the GAV details, and then click Next.
Select Payara Micro version and click Finish.
When you click Finish, the IDE creates the project.
Debugging the Application :
In the Projects window, right click on the created project and select the Debug in the pop-up menu :
Now, the IDE starts the Payara Micro instance in debug mode :
Now add the breakpoints in the program, trace the program execution step-by-step by evaluating the value of variables and diagnosethe problem.
2.b) Using the Command line :
Creating the Payara Micro Application :
Payara Micro application can be created from command line using the following maven archetype command :
Maven will ask for the project detail confirmation. Press enter or press Y and Maven will start generate the Payara Micro project.
Debugging the Payara Micro Application :
Now open the pom.xml and update the configuration of fish.payara.maven.plugins:payara-micro-maven-plugin by adding javaCommandLineOptions config under configuration tag :
Yes, you will be able to debug the application from any Java IDE. You only need to attach the debugger manually from the IDE with the specified port in pom.xml.
Can I use this post to ask how I could debug using IntelliJ Ultimate? I’ve seen some articles putting payara web profile as “add glassfish server” in intellij ultimate, but I don’t know how to do the same debug operation using payara micro?
Payara Micro is based on the Java EE web profile, To start in debug mode you need to run java command with arg “-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9009 -jar payara-micro-x.jar” or you may use Payara Micro Maven plugin and add these options in javaCommandLineOptions element and start instance using “mvn payara-micro:start”.
After running the Payara Micro instance, connect to debug port from IntelliJ IDEA as described in above comments.
Hello Gaurav
Thanks for the answer. I was able to debug the way you said, for testing purposes all right. But for real development, it would be best for an automatic way to add payara micro as if it were a glassfish server and let intellij ultimate debug it automatically. How would you do that? Isn’t there a payara micro version to be unzipped? Or use the webprofile version itself and add the payara microprofile implementation to pom?
Regards
Glad to hear that you are able to debug Payara Micro in Intellij ultimate.
I would like to highly recommend to create tickets for a new feature in Intellij issue tracker (https://youtrack.jetbrains.com/issues).
Hi Gaurav
Amazing post! Congrats!
Would I be able to debug payara micro using IntelliJ Community creating maven project (just like you did) using this debug setting in pom.xml?
Hi Fernando,
Yes, you will be able to debug the application from any Java IDE. You only need to attach the debugger manually from the IDE with the specified port in pom.xml.
I didn’t find this option in intellij. Would you know how to do it on intelliJ?
Hi Fernando,
You may manually attach debugger by creating the Remote run configuration in IntelliJ :
Goto Run menu > Edit Configuration > Click + > select Remote option > enter host & port details > Save configuration
Please follow the following StackOverflow answer for more details:
https://stackoverflow.com/questions/21114066/attach-intellij-idea-debugger-to-a-running-java-process?answertab=votes#
I just managed to debug at intelliJ community! Thank you!
Hi Gaurav
Can I use this post to ask how I could debug using IntelliJ Ultimate? I’ve seen some articles putting payara web profile as “add glassfish server” in intellij ultimate, but I don’t know how to do the same debug operation using payara micro?
Best Regards.
Payara Micro is based on the Java EE web profile, To start in debug mode you need to run java command with arg “-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9009 -jar payara-micro-x.jar” or you may use Payara Micro Maven plugin and add these options in javaCommandLineOptions element and start instance using “mvn payara-micro:start”.
After running the Payara Micro instance, connect to debug port from IntelliJ IDEA as described in above comments.
Hello Gaurav
Thanks for the answer. I was able to debug the way you said, for testing purposes all right. But for real development, it would be best for an automatic way to add payara micro as if it were a glassfish server and let intellij ultimate debug it automatically. How would you do that? Isn’t there a payara micro version to be unzipped? Or use the webprofile version itself and add the payara microprofile implementation to pom?
Regards
Hi Fernando,
Glad to hear that you are able to debug Payara Micro in Intellij ultimate.
I would like to highly recommend to create tickets for a new feature in Intellij issue tracker (https://youtrack.jetbrains.com/issues).
Few tickets are already there for Payara Server integration: https://youtrack.jetbrains.com/issue/IDEA-212638