Payara Platform Support for IntelliJ Plugin (Enterprise & Community)
Published on 02 Oct 2020by Gaurav Gupta
This tutorial describes how to create, debug and deploy a Maven web application to the Payara Platform. You may follow the same application deployment process and the Payara Platform configuration steps for a Gradle web application.
Payara IntelliJ IDEA tools provide integration of the Payara Platform Enterprise & Community Editions into IntelliJ IDEA Ultimate. Before you begin, make sure the Maven, Gradle and Payara IntelliJ tools are installed from the IntelliJ Marketplace and enabled. If not then press the following button to directly install the Payara Tools in IntelliJ Ultimate:
Or install the Payara Tools from the main menu File → Settings → Plugins and search for Payara Tools:
Creating a Payara Micro Web Application
Maven is the most widely used project build and dependency management tool in the Java ecosystem. In this tutorial we will generate a Payara Micro Maven Web Application through the Payara Micro Maven archetype. Let’s start by creating a new Project.
- Simply start up IntelliJ IDEA and then Choose File → New → Project from the main menu and select the Payara Micro project type:
- Enter the groupId, artifactId, etc to set up the project, and then click Next:
- On the Project name and Location panel, enter sample-micro-app as the project name, set the Project Location and click Finish:
- When you click Finish, the IDE creates the following projects from the Payara Micro maven archetype:
- Once the project is generated, you may either add the project to the current workspace or open in a new window:
- As you can see, the project has a basic structure with src\main\java and src\main\webapp folders:
- Now you can create the new REST Endpoint or Servlet, In the Project tool window, right-click the src/main/java directory, point to New and click Create New Servlet:
- In the New Servlet dialog, enter the name HelloServlet and click OK.
- Open the Servlet file and update the url pattern of servlet to '/hello':
In the following sections, we will deploy this application to Payara Platform.
Payara Micro application can be managed via IntelliJ Run/Debug configuration or Actions, where Run configuration can be customized by the developer and Actions are quick and easy to use:
Running the Payara Micro Application via Configuration:
IntelliJ IDEA needs a run configuration to build the artifacts and run the Payara Micro application.
- From the main menu, select Run | Edit Configurations:
- In the Run/Debug Configurations dialog, click +, expand the Payara Micro node, and select Maven.
- Now add the Before Launch tasks and assign a new artifact, click + on the left-hand pane, choose the Build Artifacts type from the drop-down list.
- In the Select Artifacts dialog, select to build the sample-micro-app:war artifact:
- Now save the configuration:
- To start the Payara Micro instance, click the run button in the top-right panel:
- After running the Payara Micro application, you may see the log in the OUTPUT window:
Debugging the Payara Micro Application
- Instead of pressing the Run button, you can instead click Debug from similar locations to automatically start the micro instance and attach the debugger to the application:
- After debugging the Payara Micro application, you may see the log in the Debug → Console window:
- After the debugger session starts and the application hits the breakpoint, the line where the servlet paused gets highlighted and the Debug tool window appears with the list of running threads and the stack-trace:
Running the Payara Micro Application via Actions:
The Payara IntelliJ tools also provide inbuilt actions to manage the Payara Micro application without creating the project configuration, which internally executes Payara Micro Maven/Gradle plugin goals/tasks:
- To invoke the actions, Goto Help menu → Find Action..:
- Search the Micro actions and press the enter key:
- Similarly, you may also debug the Payara Micro application via actions:
Deploy the Maven Web Application to Payara Server:
- To deploy the Maven application to Payara Server, we will use the same existing application and create the new Payara Server configuration by selecting the Edit Configuration option:
- In the Run/Debug Configurations dialog, click +, expand the Payara Server node, and select Local:
- To add the Payara Server to the configuration, click the Configure button and browse the Payara Server installation path:
- Fix the artifacts warnings that appear at the bottom of the run configuration settings dialog, by clicking the Fix button:
- Select the sample-micro-app:war artifact for deployment to the Payara Server:
- Now fix the debugger related warning by pressing the Fix button, which updates the debugger settings in the domains.xml of the selected Payara Server’s domain:
- Now save the configuration:
- Click the Run or Debug button from top-right panel that starts the Payara Server and deploys the artifact to the server:
- After application deployed to the Payara Server, IntelliJ starts a web browser and opens the application home page URL in the web browser:
- You may see the log in the Services → Payara Log window:
Currently, the Payara IntelliJ tools are only available for IntelliJ Ultimate Edition. In the upcoming release, Payara Micro tools will also be released for IntelliJ Community Edition with addition to some new cool features like Payara Micro Gradle project generator and Hot Deploy support.