Deploying a WAR File
Deploying a WAR File
Appkit runs in most Java servlet containers including Apache Tomcat, Jetty and GlassFish. The majority of our customers use Tomcat 8 for production systems.If using Tomcat, see the troubleshooting page for information on configuring the use of UTF-8 character encoding. (This resolves the most common issues with special characters.)Follow these steps to deploy an Appkit .war file:
-
Ensure that Java 8 JDK Java 1.8 is installed.
We do not recommend OpenJDK, which is installed by default in various Linux distributions. We recommend using the Oracle JDK only.
- Install your servlet container of choice, such as Tomcat 8.
-
You will have been provided a web application archive (.war file) that contains an Appkit web application (such as
twigkit-search.war
). If using Tomcat, copy the provided .war file into Tomcat’s webapps folder. - Start the servlet container.
-
Several seconds later, a folder with the same name as the .war file will appear in the file system (for example, twigkit-search). You can then access the application in your browser at
http://localhost:8080/{contextPath}
, where{contextPath}
is the name of the .war file (for example,http://localhost:8080/twigkit-search/
). You can also access the Appkit logs in the file system at{tomcat}/logs/catalina.out
.
Install Java 7+ JDK, Git and Maven for your platform
- Download and install the Oracle (SUN) Java SE JDK 1.8.
- Install npm 9.0.2.
-
Configure Maven by saving the following
settings.xml
file in your Maven configuration folder within your App Studio Enterprise project (/bin/settings.xml
). See the Maven Settings Reference for more information.
Download App Studio Enterprise
Go to the App Studio Enterprise download page and download the latest copy.Run the web application
After you have downloaded the Git project, you can run the application using the included start scripts. Enter this command from the project folder:http://localhost:8080/
.
Package the web application
To package the web application for deployment (rather than run it locally), you can run this command from the project folder:/target
folder you will find both the WAR file and the self-starting one, for example, app-studio-enterprise.jar
(note the .jar suffix). To run the application use:
Use build profiles to package the web application for different runtime environments
Often the only differences between applications deployed to different environments are in the resources, that is, configuration settings, security configuration, or in the license key that is used. To facilitate these differences Appkit also provides the capability to configure which runtime environment you want to deploy to when packaging an application for distribution. To configure an application for different environments, the resources to be deployed to a particular environment are stored insrc/main/profiles/<environment>
in the source code tree. The assumption being that the main source tree will continue to contain all the resources intended for the production
build of the application (that is, src/main/resources
). For example, to configure an application for use in three different environments, in this case dev
, staging
, and eventually production
, the source tree could be set up as follows:
-P
flag. For example, to deploy to the dev
environment you would use this command:
production
build. The profile resources are only merged with main resources in the pre-packaging phase of the build after they are in the target/classes
directory.
After the application has been packaged, the war and jar files associated with that particular application profile will be stored under the application’s dist/<environment>
directory where <environment>
is the name given to the build profile. For example:
dev
environment, another for the staging
environment, and finally one for the production
environment. The <application-name>
would be replaced by the name of the application. The application version number is appended to the production jar file.
To test a profile locally, you can use its self-starting archive JAR file. To run the application, navigate to the directory the JAR file is in and use this command:
<application-name>
with the actual name of the application.
Develop a Maven build profile by overlaying configurations
Together with configuring different build profiles for different runtime environments, Appkit also offers the ability to deploy a WAR File via the Jetty Maven plugin. This can be very useful when you want to test whether specific values can be used in the build profile prior to deployment. By default, when a build profile is run via the Jetty Maven plugin, a default overlay will also be used if it is placed insrc/dev/resources/conf
:
-Dtwigkit.conf.overlay
:
The overlay is purely meant for development. It will not be used when an app is deployed (via
mvn clean package
). During this phase, any resource under the build profile will overwrite the equivalent resource in the main app.