Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 9. Packaging your application
This sections contains information about packaging your Thorntail–based application for deployment and execution.
9.1. Packaging Types Copier lienLien copié sur presse-papiers!
When using Thorntail, there are the following ways to package your runtime and application, depending on how you intend to use and deploy it:
9.1.1. Uberjar Copier lienLien copié sur presse-papiers!
An uberjar is a single Java .jar file that includes everything you need to execute your application. This means both the runtime components you have selected—you can understand that as the app server—along with the application components (your .war file).
An uberjar is useful for many continuous integration and continuous deployment (CI/CD) pipeline styles, in which a single executable binary artifact is produced and moved through the testing, validation, and production environments in your organization.
The names of the uberjars that Thorntail produces include the name of your application and the -thorntail.jar suffix.
An uberjar can be executed like any executable JAR:
java -jar myapp-thorntail.jar
$ java -jar myapp-thorntail.jar
9.1.2. Hollow JAR Copier lienLien copié sur presse-papiers!
A hollow JAR is similar to an uberjar, but includes only the runtime components, and does not include your application code.
A hollow jar is suitable for deployment processes that involve Linux containers such as Docker. When using containers, place the runtime components in a container image lower in the image hierarchy—which means it changes less often—so that the higher layer which contains only your application code can be rebuilt more quickly.
The names of the hollow JARs that Thorntail produces include the name of your application, and the -hollow-thorntail.jar suffix. You must package the .war file of your application separately in order to benefit from the hollow JAR.
Using hollow JARs has certain limitations:
To enable Thorntail to autodetect a JDBC driver, you must add the JAR with the driver to the
thorntail.classpathsystem property, for example:java -Dthorntail.classpath=./h2-1.4.196.jar -jar my-hollow-thorntail.jar myApp.war
$ java -Dthorntail.classpath=./h2-1.4.196.jar -jar my-hollow-thorntail.jar myApp.warCopy to Clipboard Copied! Toggle word wrap Toggle overflow YAML configuration files in your application are not automatically applied. You must specify them manually, for example:
java -jar my-hollow-thorntail.jar myApp.war -s ./project-defaults.yml
$ java -jar my-hollow-thorntail.jar myApp.war -s ./project-defaults.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
When executing the hollow JAR, provide the application .war file as an argument to the Java binary:
java -jar myapp-hollow-thorntail.jar myapp.war
$ java -jar myapp-hollow-thorntail.jar myapp.war
9.1.2.1. Pre-Built Hollow JARs Copier lienLien copié sur presse-papiers!
Thorntail ships the following pre-built hollow JARs:
- web
- Functionality focused on web technologies
- microprofile
- Functionality defined by all Eclipse MicroProfile specifications
The hollow JARs are available under the following coordinates:
<dependency>
<groupId>io.thorntail.servers</groupId>
<artifactId>[web|microprofile]</artifactId>
</dependency>
<dependency>
<groupId>io.thorntail.servers</groupId>
<artifactId>[web|microprofile]</artifactId>
</dependency>
9.2. Creating an uberjar Copier lienLien copié sur presse-papiers!
One method of packaging an application for execution with Thorntail is as an uberjar.
Prerequisites
-
A Maven-based application with a
pom.xmlfile.
Procedure
Add the
thorntail-maven-pluginto yourpom.xmlin a<plugin>block, with an<execution>specifying thepackagegoal.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Perform a normal Maven build:
mvn package
$ mvn packageCopy to Clipboard Copied! Toggle word wrap Toggle overflow Execute the resulting uberjar:
java -jar ./target/myapp-thorntail.jar
$ java -jar ./target/myapp-thorntail.jarCopy to Clipboard Copied! Toggle word wrap Toggle overflow