When creating a Java EE application it is important to deploy and test it on a server that is as close to the target production environment as possible. If you use Maven in your project, it is possible to do so using the Cargo plugin, which allows you to deploy an application to an instance of Payara Server either locally or remotely. A complete example is available at https://github.com/payara/Payara-Examples/tree/master/payara-maven.
The cargo plugin can be added to a Maven project by adding the following to the
<plugins> section of the pom:
There are four common goals you may use in your execution:
startruns goal start to start a local Payara server in background (not possible with remote deployment type)
redeployruns goal redeploy to deploy the built application (will undeploy if needed)
undeployruns goal undeploy to undeploy the built application
stopruns goal stop to stop the server running in background (not possible with remote deployment type)
An example of how you might use those goals to run an integration test:
Deploying to a Remote Instance of Payara Server
To deploy to a remote instance of Payara Server add the following configuration to the profile you are using:
A few important points to note about this configuration:
- The default username for Cargo is admin.
- The default password is adminadmin. If you have no password, then use “” as Cargo will throw an error if the password field is empty.
- The default admin port is 4848.
- The default hostname is localhost.
stopexecution goals cannot be used with a remote Payara Server instance; this means that the remote instance MUST be running, otherwise Maven will fail.
Deploying to a Local Instance of Payara Server
To deploy to a local instance of Payara Server add the following to the profile you are using:
The full path to the Payara Server home, domains directory and domain name must be specified i.e.
Further information about the plugin is available at https://codehaus-cargo.github.io/cargo/GlassFish+5.x.html.