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
- First, create a project using the new project wizard. Go to the Maven category, and select 'Project from Archetype'. Click next.
- 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
Payara Server now has a set of NetBeans plugins for better integration. This allows you to add Payara Server as a recognised server in NetBeans and then deploy and manage applications from the Netbeans interface. Adding the Payara NetBeans plugins can be done with the following steps:
- Go to Tools → Plugins.
- In the 'Available Plugins' tab search for 'Payara', then check all of the available checkboxes. This will include the main plugin as well as common libraries for accessing Payara Server.
3. After the plugin installation, click the Finish button to restart the NetBeans IDE.
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 and click Add Server.
- Select Payara Server, and name the server whatever you want. For this example I've named it 'Payara'. Click next.
3. Select the location of the 'payara41' directory from the extracted Payara Server. Read and accept the license agreement. Click next.
4. Select a domain. A domain is essentially a server at runtime. Unless you've created your own, you can use domain1 as it's the default domain. Enter 'admin' as the username and leave the password field blank.
5. 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.