Deploying to Payara Deployment Group Using the Maven Cargo Plugin
Published on 12 Mar 2021
by Rudy De BusscherIntroduction
The Apache Maven Cargo Plugin allows you to deploy your application to a Payara Server, running locally or remotely. Using Maven as a build tool is an easy way to immediately deploy the application during the build to a test or production server.
We have created a custom version of the Cargo Plugin which also supports the Deployment Group feature of the Payara Server.
You can read how to use the plugin in the Deploying to Payara Server using the Cargo Plugin blog in more detail.
The Deployment Group is the clustering technique within Payara Server to have your application running on multiple instances so user requests can be divided over multiple machines and thus increases the number of user requests that can be handled by your environment.
We have created a custom version of the Cargo Plugin which also supports the Deployment Group feature of the Payara Server.
Cargo Plugin
The Cargo plugin supports the JSR-88 specification of Java EE which means it can deploy and undeploy any application to a compliant server. Payara Server also supports this specification and as you can read in the blog https://blog.payara.fish/deploying-to-payara-server-using-the-maven-cargo-plugin it allows you to interact directly with Payara Server using the Cargo plugin.
The Deployment Group functionality in Payara Server is not a standard functionality of Java EE or Jakarta EE. This means that you can experience some issues when specifying a Deployment Group as the target in the Cargo Plugin. For example, when you ask for a redeploy to the local-group
, you get the message:
[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.7.7:redeploy (default-cli) on project demo:
Execution default-cli of goal org.codehaus.cargo:cargo-maven2-plugin:1.7.7:redeploy failed:
Cannot communicate with the server: Error getting required modules: remote command execution failed on the server: Target local-group is not a supported type.
Command _list-app-refs supports these types of targets only: Stand alone instance, Config, Cluster, Default server,
Custom Version of the Cargo Plugin
To overcome the issues described above, we have created a custom version of the Cargo Plugin that correctly supports the Deployment Group functionality of the Payara Server. Here are the steps to use it:
1. Add the Payara Patched Projects as Plugin repository to the Maven POM file.
<pluginRepositories>
<pluginRepository>
<id>Payara Patched projects</id>
<url>https://raw.github.com/payara/Payara_PatchedProjects/master</url>
</pluginRepository>
</pluginRepositories>
2. Define the customer version of the plugin.
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.8.4.payara-p1</version>
<configuration>
...
</plugin>
The 1.8.4.payara-p1
version, only available within our repository on GitHub, has the capabilities to handle the Deployment Groups of the Payara Server correctly.
3. Use the configuration as before.
We did not make any change to the configuration, you can just use the Deployment Group name as the target property name.
<properties>
<cargo.runtime.args>force=true</cargo.runtime.args>
<cargo.remote.username>${username}</cargo.remote.username>
<cargo.remote.password>${password}</cargo.remote.password>
<cargo.glassfish.admin.port>4848</cargo.glassfish.admin.port>
<cargo.hostname>${hostname}</cargo.hostname>
<cargo.glassfish.target>local-group</cargo.glassfish.target>
</properties>
Deploy Applications to Payara Server Deployment Group with Maven
Using the Maven Cargo Plugin is an alternative to deploy your applications to the Payara Server in situations you do not have the Asadmin Command Line (Asadmin CLI) tool available. It is especially useful when you are using Maven as your build tool as it can be configured to be part of the build phases.
With the updated version we have created, you can also deploy to a Deployment Group and not only to the DAS server, instance, or a Cluster.
Related Posts
Payara Cloud Connectivity: Linking Your Apps to Essential Backend Services
Published on 19 Aug 2024
by Luqman Saeed
0 Comments
Payara Cloud, our increasingly popular Payara as a Service (PaaS) offering, automates the cloud deployment of your Jakarta EE and MicroProfile applications, making it easy to connect to essential services that your application relies on. This ...
Ensuring Seamless Operations and Maximum Profitability: Key Insights on Application Server Efficiency and SLAs - Part 2
Published on 12 Aug 2024
by Chiara Civardi
0 Comments