Chapter 3. Provisioning a server by using the JBoss EAP Maven plug-in
You can provision a server by using the JBoss EAP Maven plug-in both for bare metal and OpenShift Container Platform.
3.1. Provisioning a server for bare metal platforms by using the JBoss EAP Maven plug-in Copy linkLink copied to clipboard!
Traditionally, you would install JBoss EAP using one of the installation methods such as using the installation manager and then deploy applications to the server. Instead of having to first install the server, you can simply provision a server when you build your application with the application deployed to the provisioned server.
Prerequisites
You have created a Maven project for a JBoss EAP application.
For more information, see Creating a Maven project for a hello world application.
Procedure
Define the following property in the
pom.xmlconfiguration file:<properties> ... <version.plugin.eap>2.0.0.Final-redhat-00009</version.plugin.eap>1 </properties>- 1
<version.plugin.eap>is provided as an example. See the Red Hat Maven repository for more information on JBoss EAP Maven plugin releases: org/jboss/eap/plugins/eap-maven-plugin/. For JBoss EAP 8.1, the latest major 2.x version is required.
Add the JBoss EAP maven plugin to
<pluginManagement>, in<build>section inside the<project>section.<project> ... <build> <pluginManagement> <plugins> ... <plugin> <groupId>org.jboss.eap.plugins</groupId> <artifactId>eap-maven-plugin</artifactId> <version>${version.plugin.eap}</version> </plugin> </plugins> </pluginManagement> </build> </project>Add the
eap-maven-pluginin thepom.xmlconfiguration file. In the following examples, the plug-in is included within different profilesprovisioned-serverandbootable-jar.Create a profile for server provisioning.
<project> ... <profiles> ... <profile> <id>provisioned-server</id> <activation> <activeByDefault>true</activeByDefault>1 </activation> <build> <plugins> <plugin> <groupId>org.jboss.eap.plugins</groupId> <artifactId>eap-maven-plugin</artifactId> <configuration> <channels>2 <channel> <manifest> <groupId>org.jboss.eap.channels</groupId> <artifactId>eap-8.1</artifactId> </manifest> </channel> </channels> <feature-packs> <feature-pack>3 <location>org.jboss.eap:wildfly-ee-galleon-pack</location> </feature-pack> </feature-packs> <layers>4 <layer>datasources-web-server</layer> </layers> </configuration> <executions> <execution> <goals> <goal>package</goal>5 </goals> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles> </project>- 1
- Set
activeByDefaulttotrueto activate this profile by default. - 2
- Define the channels from which the feature-packs are to be fetched.
- 3
- Define the feature-packs that should be used. In this example,
org.jboss.eap:wildfly-ee-galleon-packfeature-pack is used. For information about the layers that this feature-pack includes, see wildfly-ee-galleon-pack layers. - 4
- Define the layers from the configured feature-packs to include in the provisioned server. This example uses datasources-web-server. For information about datasources-web-server, see datasources-web-server.
- 5
- Define the goal for provisioning the server. This example uses the
packagegoal which provisions the server with the application packaged. To provision a server without the application packaged, use theprovisiongoal.
Create a profile for bootable JAR.
<project> ... <profiles> ... <profile> <id>bootable-jar</id> <activation> <activeByDefault>true</activeByDefault>1 </activation> <build> <plugins> <plugin> <groupId>org.jboss.eap.plugins</groupId> <artifactId>eap-maven-plugin</artifactId> <configuration> <channels>2 <channel> <manifest> <groupId>org.jboss.eap.channels</groupId> <artifactId>eap-8.1</artifactId> </manifest> </channel> </channels> <feature-packs> <feature-pack>3 <location>org.jboss.eap:wildfly-ee-galleon-pack</location> </feature-pack> </feature-packs> <layers>4 <layer>datasources-web-server</layer> </layers> <bootable-jar>true</bootable-jar>5 </configuration> <executions> <execution> <goals> <goal>package</goal>6 </goals> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles> </project>- 1
- Set
activeByDefaulttotrueto activate this profile by default. - 2
- Define the channels from which the feature-packs are to be fetched.
- 3
- Define the feature-packs that should be used. In this example, org.jboss.eap:wildfly-ee-galleon-pack is used. For information about the layers that this feature-pack includes, see wildfly-ee-galleon-pack layers.
- 4
- Define the layers to provision the server with. This example uses datasources-web-server. For information about datasources-web-server, see datasources-web-server
- 5
- Provision the server as a bootable JAR.
- 6
- Define the goal for provisioning the server. This example uses the
packagegoal which provisions the server with the application packaged. To provision a server without the application packaged, setskipDeploymenttotrue.
NoteYou cannot use the
provisiongoal when you set the value of thebootable-jarattribute totrue.
- If your Maven project does not contain an application, create the application as usual, for example, see Creating a hello world servlet.
Provision the server by building the application.
$ mvn packageNoteIf you use the
mvn packagecommand with debugging enabled (-Xoption), include the property-Dorg.slf4j.simpleLogger.log.com.networknt.schema=offto prevent excessive debug logging during schema validation.
Verification
Start the application.
To start the application with the provisioned server, use the following commands:
Navigate to the directory containing the provisioned server.
$ cd target/server/standalone/binStart the server.
$ ./standalone.sh
To start the application as bootable JAR, use the
java -jarcommand:java -jar target/<application-name>.jar
3.2. Provisioning a server for OpenShift Container Platform by using the JBoss EAP Maven plug-in Copy linkLink copied to clipboard!
Provision a server for OpenShift Container Platform that only includes the required capabilities by using the JBoss EAP Maven plug-in.
Prerequisites
You have created a Maven project for a JBoss EAP application.
For more information, see Creating a Maven project for a hello world application.
Procedure
Define the following property in the
pom.xmlconfiguration file:<properties> ... <version.plugin.eap>2.0.0.Final-redhat-00009</version.plugin.eap>1 </properties>- 1
<version.plugin.eap>is provided as an example. See the Red Hat Maven repository for more information on JBoss EAP Maven plugin releases: org/jboss/eap/plugins/eap-maven-plugin/. For JBoss EAP 8.1, the latest major 2.x version is required.
Add the JBoss EAP maven plugin to
<pluginManagement>, in<build>section inside the<project>section.<project> ... <build> <pluginManagement> <plugins> ... <plugin> <groupId>org.jboss.eap.plugins</groupId> <artifactId>eap-maven-plugin</artifactId> <version>${version.plugin.eap}</version> </plugin> </plugins> </pluginManagement> </build> </project>Add the eap-maven-plugin in the
pom.xmlconfiguration file. In the following examples, the plug-in is included within theOpenShift Container Platformprofile.<profiles> <profile> <id>openshift</id> <build> <plugins> <plugin> <groupId>org.jboss.eap.plugins</groupId> <artifactId>eap-maven-plugin</artifactId>1 <configuration> <channels> <channel> <manifest> <groupId>org.jboss.eap.channels</groupId> <artifactId>eap-8.1</artifactId> </manifest> </channel> </channels> <feature-packs> <feature-pack>2 <location>org.jboss.eap:wildfly-ee-galleon-pack</location> </feature-pack> <feature-pack> <location>org.jboss.eap.cloud:eap-cloud-galleon-pack</location> </feature-pack> </feature-packs> <layers>3 <layer>cloud-server</layer> </layers> </configuration> <executions> <execution> <goals> <goal>package</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles>- 1
eap-maven-pluginis a JBoss EAP plug-in.- 2
- Define the feature-packs that should be used. In this example,
org.jboss.eap:wildfly-ee-galleon-packfeature-pack is used. For information about the layers that this feature-pack includes, see wildfly-ee-galleon-pack layers. Theorg.wildfly.cloud:wildfly-cloud-galleon-packfeature-pack is required for OpenShift. - 3
- Define the layers from the configured feature-packs to include in the provisioned server. This example uses the
cloud-serverlayer, which provisions just the basic features of JBoss EAP, for OpenShift. For information about thecloud-serverlayer, see cloud-server. <name>ROOT.war</name>: Defines the resulting name of the application’s web archive (WAR). IfROOT.waris specified then the application is deployed at the root path of the server, otherwise it is deployed at<name/>relative path.
ImportantBootable jar is not supported on OpenShift Container Platform.
- If your Maven project does not contain an application, create the application as usual, for example, see Creating a hello world servlet.
Provision the server by building the application.
$ mvn packageNoteIf you use the
mvn packagecommand with debugging enabled (-Xoption), include the property-Dorg.slf4j.simpleLogger.log.com.networknt.schema=offto prevent excessive debug logging during schema validation.
Verification
-
You can check the generated server configuration file
target/server/standalone/configuration/standalone.xmlthat contains the provisioned subsystems and application deployment.
The JBoss EAP server that contains your deployment has been provisioned.