Strict Standards: Declaration of action_plugin_siteexport_ajax::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /homepages/24/d93998614/htdocs/www.hammurapi.com/dokuwiki/lib/plugins/siteexport/action/ajax.php on line 17

Strict Standards: Declaration of action_plugin_siteexport_startup::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /homepages/24/d93998614/htdocs/www.hammurapi.com/dokuwiki/lib/plugins/siteexport/action/startup.php on line 39

Strict Standards: Declaration of action_plugin_tag::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /homepages/24/d93998614/htdocs/www.hammurapi.com/dokuwiki/lib/plugins/tag/action.php on line 117

Strict Standards: Declaration of action_plugin_jcapture::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /homepages/24/d93998614/htdocs/www.hammurapi.com/dokuwiki/lib/plugins/jcapture/action.php on line 47

Strict Standards: Declaration of action_plugin_statistics::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /homepages/24/d93998614/htdocs/www.hammurapi.com/dokuwiki/lib/plugins/statistics/action.php on line 51

Strict Standards: Declaration of action_plugin_keywords::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /homepages/24/d93998614/htdocs/www.hammurapi.com/dokuwiki/lib/plugins/keywords/action.php on line 65

Warning: ob_start(): function 'compress_handler' not found or invalid function name in /homepages/24/d93998614/htdocs/www.hammurapi.com/mantis/core.php on line 39

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 [Hammurapi Group]

WAR Launcher

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.

How it works

WAR Launcher bundles Winstone Servlet Container into the target WAR file and adds launcher class and helper classes to launch Winstone.

Download warlauncher.jar and execute

java -jar warlauncher.jar <war file> [<winstone properties file>]

e.g.

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 launcher.WinstoneLauncher.

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:

winstone.properties
httpPort=80

Setting warfile option has no effect because the launcher sets this option to the target WAR file absolute path.

Install as Windows service

To install the modified war as a Windows service execute:

java -jar <war name> --install-service [jvm_option:<jvm option>...]

e.g.

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>

e.g.

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. jxptest_out.log and jxptest_err.log).

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"

Special notes

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.JxpServlet from 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.

web.xml
<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.

Wrapping as a native executable

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.

License

  • Hammurapi Group files - GPL.
  • winstone.jar - LGPL or CDDL.
  • JavaService - LGPL.

Files

FilenameFilesizeLast modified
com.hammurapi.jxp-src.zip2.4 K2011/06/22 00:19
com.hammurapi.jxp.jar4.2 K2011/06/22 00:19
jxptest.war740.2 K2011/06/22 19:10
warlauncher-src.zip5.1 K2011/06/22 19:10
warlauncher.jar430.4 K2011/06/22 19:10
Last modified: 2011/06/24 10:16 by Pavel Vlasov
   
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Hammurapi Group