SYSTEM WARNING: Cannot modify header information - headers already sent by (output started at /homepages/24/d93998614/htdocs/www.hammurapi.com/dokuwiki/lib/plugins/siteexport/action/ajax.php:17)
WAR launcher is a utility which converts a WAR file into an executable JAR, thus obviating the servlet container (with some limitations). The modified WAR file can still be deployed as a regular WAR file to a servlet container. It can also be installed as a Windows service. Both 32 and 64 bit JVM's are supported.
This triple nature of a modified (instrumented) WAR file allows to distribute web applications to end users without a hassle of setting up a servlet container on the end user machine, blurring the line between a server application and a desktop application.
WAR Launcher bundles Winstone Servlet Container into the target WAR file and adds launcher class and helper classes to launch Winstone.
warlauncher.jar and execute
java -jar warlauncher.jar <war file> [<winstone properties file>]
java -jar warlauncher.jar jxptest.war winstone.properties
WAR Launcher will add
launcher directory to the WAR file and add/replace
META-INF/MANIFEST.MF with a manifest file which sets the main class to
If properties file is provided then the launcher class will read properties from the file and pass them to Winstone. A list of supported properties is provided here. Do not add -- before property names. Example:
warfile option has no effect because the launcher sets this option to the target WAR file absolute path.
To install the modified war as a Windows service execute:
java -jar <war name> --install-service [jvm_option:<jvm option>...]
java -jar jxptest.war --install-service jvm_option:-Xmx128m
WAR launcher uses JavaService to wrap a war into a Windows service. JavaService files get injected into the target WAR along with winstone.jar and launcher classes. WAR launcher automatically detects the path to
jvm.dll and the JVM architecture - 32 or 64 bit. It creates
<war name without extension>.exe file and executes it to install the service. To uninstall the service execute
<service exe> -uninstall <service name>
jxptest.exe -uninstall jxptest
Service standard out and err are redirected to
<war name without extension>_out.log and
<war name without extension>_err.log respectively (e.g.
If the WAR file name contains spaces, put quotes around the WAR name during installation and the service name during uninstallation, e.g.
java -jar "My Web Application.war" --install-service jvm_option:-Xmx128m "My Web Application.exe" -uninstall "My Web Application"
Winstone doesn't support JSP's OOTB. It is possible to add JSP support (see Winstone documentation) but it will somewhat defeat the purpose of winstone bundling by introducing additional setup steps.
An alternative to JSP's it to use JXP. The OOTB JXP servlet doesn't work, so use
com.hammurapi.jxp.jar (see the files section). This servlet is an almost literal copy of the OOTB JxpServlet with some modifications to make it work.
The code snippet below shows how to add jxp servlet definitions to the web.xml descriptor.
<servlet> <servlet-name>jxp-servlet</servlet-name> <servlet-class>com.hammurapi.jxp.JxpServlet</servlet-class> </servlet> <!-- The mapping for the jxp servlet --> <servlet-mapping> <servlet-name>jxp-servlet</servlet-name> <url-pattern>*.jxp</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>jxp-servlet</servlet-name> <url-pattern>/JxpServlet</url-pattern> </servlet-mapping>
/JxpServlet mapping shows Jxp processor environment variables - it is useful during development and can be commented out/removed from the final product.
jxptest.war demonstrates use of JXP's and Winstone bundling. Download it and either deploy to a servlet container or execute as a jar file. Then open
http://localhost:8080/ in a web browser.
To make your web application even easier to install, you can use Launch4j to convert it to a native executable and bundle JRE with it.