2 Running the application - Reference Documentation
Authors: Burt Beckwith
Version: 8.0.33
2 Running the application
Building the jar
The first step is to run the build-standalone script, e.g.grails prod build-standalone
grails -Dgrails.env=demo build-standalone our_cool_demo.jar
grails prod build-standalone --jetty
grails -Dgrails.env=demo build-standalone our_cool_demo.jar --jetty
grails.plugin.standalone.useJetty = truegrails build-standalone --tomcat
Build Configuration
There are several configuration settings that you can use to change how the jar is built; add any of these to BuildConfig.groovy to override the defaults:| Property | Default Value | Meaning |
|---|---|---|
| grails.plugin.standalone. ecjDependency | 'org.eclipse.jdt.core.compiler:ecj:4.5.1' | the dependency config for the ECJ jar |
| grails.plugin.standalone. extraDependencies | none | extra dependency jars to include in the standalone jar |
| grails.plugin.standalone. ivyLogLevel | 'warn' | the Ivy log level |
| grails.plugin.standalone. jettyServletApiDependency | 'javax.servlet:servlet-api:2.5' or 'javax.servlet:javax.servlet-api:3.1.0' | the Jetty servlet API jar dependency |
| grails.plugin.standalone. jettyVersion | '7.6.0.v20120127' | the version of Jetty to use |
| grails.plugin.standalone. tomcatVersion | '8.0.33' | the version of Tomcat to use |
| grails.plugin.standalone. tomcatDependencies | 'tomcat-annotations-api', 'tomcat-api', 'tomcat-catalina-ant', 'tomcat-catalina', 'tomcat-coyote', 'tomcat-juli', 'tomcat-servlet-api', 'tomcat-util' | the Tomcat jars to use |
| grails.plugin.standalone. tomcatEmbedDependencies | 'tomcat-embed-core', 'tomcat-embed-el', 'tomcat-embed-jasper', 'tomcat-embed-logging-juli', 'tomcat-embed-logging-log4j', 'tomcat-embed-websocket' | the Tomcat embed jars to use |
| grails.plugin.standalone. mainClass | 'grails.plugin.standalone. JettyLauncher' or 'grails.plugin.standalone. Launcher' | Optionally specify a custom main class to include in the MANIFEST.MF. Note that you will then be required to call either grails.plugin.standalone. JettyLauncher or grails.plugin.standalone. Launcher yourself |
Running the server
As long as the target machine has Java 5 or higher available, all you need to do next is runjava -jar /path/to/jar_name.jar
name=value syntax:
context, the context name; if not specified it defaults to "" (the "root" context)host, the host name; if not specified it defaults to "localhost"port, the HTTP port; if not specified it defaults to 8080httpsPort, the HTTPS port; there is no default for this, but if specified you can also specify the keystore path and passwordkeystorePathorjavax.net.ssl.keyStore, the SSL keystore path; if not specified a temporary keystore will be generatedkeystorePasswordorjavax.net.ssl.keyStorePassword, the SSL keystore password; required if an existing keystore path is specifiedtruststorePathorjavax.net.ssl.trustStore, the SSL truststore pathtrustStorePasswordorjavax.net.ssl.trustStorePassword, the SSL truststore password; required if an existing truststore path is specifiedenableClientAuth, whether to enable client auth, defaults to falseworkDir, the working directory where the war file is extracted, defaults to the system temp directoryenableCompression, whether to enable compression (Tomcat only)compressableMimeTypes, a comma separated list of MIME types for which HTTP compression may be used; defaults to the Tomcat defaults,"text/html,text/xml,text/plain"sessionTimeout, the session timeout in minutes; defaults to 30nioortomcat.nio, whether to use NIO; defaults to trueserverName, a specific value to use as HTTP Server Header, by default tomcat will use Apache-Coyote/1.1 if none set at application level (Tomcat only)enableProxySupport, enables support for X-Forwarded headers by adding a pre-configured RemoteIpValve, defaults to false (Tomcat only)
java -jar /path/to/jar_name.jar
http://localhost:8080/ andjava -jar /path/to/jar_name.jar context=cool_demo port=9000
http://localhost:9000/cool_demojava -jar /path/to/jar_name.jar context=cool_demo port=8080 httpsPort=8443
http://localhost:8080/cool_demo and will also support SSL at https://localhost:8443/cool_demo