Skip to content
Grails plugin to make Grails war files executable (java -jar myapp.war) by embedding Jetty
Groovy Java
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

War-Exec Plugin

Grails plugin to make Grails war files executable (java -jar myapp.war) by embedding Jetty. Jetty can be configured using properties in Config.groovy.


Install the plugin:

grails install-plugin war-exec

Add a dependency to BuildConfig.groovy:

plugins {
    runtime ":war-exec:1.0.4"

Now you can do:

$ grails dev war
$ java -jar target/com.brandseye.myapp.war

Your application will be running with your development environment configuration. If you just do "grails war" the war file is configured for your production environment. Note that the war file can still be deployed to Tomcat et al normally if needed.

Jetty listens on the grails.server.port.http from BuildConfig.groovy (8080 by default). You can set this and other properties in Config.groovy (and have different values for different environments):
jetty.context.path=... // defaults "/" for production wars otherwise to what grails run-app uses
jetty.tmp=...    // where the war file is unpacked, defaults to ${user.home}/.jetty-tmp

These be overridden using system properties:

java -jar myapp.jar

The property can contain more than one host separated by commas:,

Additionally each host can have its own port (use / as separator from the host address):,

How It Works

The Jetty jars are pulled in via a runtime dependency in BuildConfig.groovy.

A ''eventCreateWarStart'' event handler in scripts/_Events.groovy unpacks jetty-.jar and servlet-api-.jar into the root of the war file and deletes them from from WEB-INF/lib. It also sets the Main-Class in the MANIFEST.MF file to standalone.Start (src/java/standalone/ and creates standalone/ containing jetty.* properties from Config.groovy. The Start class uses these to configure Jetty.

Proxying Your Application Using Apache

Make sure mod_proxy and mod_proxy_http are loaded and enabled:

LoadModule proxy_module modules/
LoadModule proxy_http_module modules/

Then you can configure the virtual hosts to proxy your application:

<VirtualHost *:80>

  ProxyRequests off
  <Proxy *>
  Order deny,allow
  Allow from all

  ProxyPass / http://localhost:8080/
  ProxyPreserveHost On

Note that this works with HTTPS virtual hosts as well.


1.0.4: 25 July 2019: Jetty directory listing disabled

1.0.3: 8 May 2013: Jetty connector now has forwarded=true so X-Forwarded-For etc. are picked up and request.getRemoteAddr() works properly

1.0.2: 7 Jan 2013: Added support for listening on multiple hosts with different ports.

You can’t perform that action at this time.