When testing an app to be run on Payara Server, it can be extremely useful to be able to test your app continuously in your IDE - after all, that’s what it’s there for! If you're using NetBeans, this is made very easy. Follow the steps in this blog to setup the Payara Server in NetBeans for running your web apps.
If you haven't made a project to test yet, carry on to the first section of this guide. If you already have an app to run, then you can skip this section.
Creating a Test Application with Maven
1. First, create a project using the new project wizard. Go to the Maven category, and select 'Project from Archetype'. Click next.
2. Select the archetype named 'maven-archetype-webapp'. Click next.
3. Select a project name and group ID. The bottom 4 settings are for Maven. For naming conventions use the following page: https://maven.apache.org/guides/mini/guide-naming-conventions.html
4. You've successfully made your first web app for deploying to Payara Server!
Adding Payara Server to NetBeans
Now that you've got your project set up, you need to setup the Payara Server itself. The setup is done using the following steps:
- Go to Tools → Servers.
- Select GlassFish Server, and name the server whatever you want. For this example I've named it 'Payara 22.214.171.124', as that's the version I'm using. Click next.
- Select the location of the 'payara41' directory from the extracted Payara Server. Read and accept the license agreement. Click next.
- Select a domain. A domain is essentially a server at runtime. Unless you've created your own, use domain1 as it's the default domain. Enter 'admin' as the username and leave the password field blank.
- The server is now created! Make sure the details are all correct on this screen. I've also disabled the option 'Start Registered Derby Server' as the test app we've made doesn't use it, so it will speed up server startup time slightly. If you need the database, then leave this box checked.
6. After exiting this window, right click your test project and select 'Run', followed by selecting the server you just created. The server will start up and you should eventually be greeting with a 'Hello World!' message in your browser.
To stop the server, switch to the server log at the bottom of the window under Output → 'Name of created server'. Click the stop sign in this window.
That's how to add Payara Server to NetBeans! You are now able to run any project on Payara Server in a similar fashion to this one.