Run Grails application as standalone application

29 / Jul / 2016 by Sanchit . 2 comments

Most Grails application are intended to deploy within external container. According to the traditional way of deployment, the apps are bundled as war packaging, deploy it into any external container like tomcat and Jetty.

There is a plugin Standalone App Runner which allow to em-bade a container inside the grails application itself. The advantage of that is that a Gails application can be run as a standalone application , without any dependency of external container.

The embadded container comes up with application up and stop when we stop the application. To use this add the plugin dependencies in BuildConfig.groovy

[java]
compile "org.grails.plugins:standalone:9.0.0.M4"
[/java]

To create the Jar file with embadded container :

[java]
grails build-standalone
[/java]

To Run the Jar file as a stand alone application :

[java]
java -jar /path/to/jar_name.jar
[/java]

We can also pass the environment variables while running the jar to run the container with a specific environment configuration :

[java]
grails -Dgrails.env=prod build-standalone jar_name.jar
[/java]

This plugin has both Tomcat and Jetty container functionality, we can set the jetty as a default container. For that we need to specify that in BuildConfig.groovy :

[java]
grails.plugin.standalone.useJetty = true
[/java]

Also it can bs specify at the time of deployment which server will be used to run the application. we can specify the flag values for perticular container.

[java]
grails build-standalone –tomcat
grails build-standalone –jetty
[/java]

It removes the external container dependency and easily integrate with the application. And the Grails application can be run as standalone application with Jar packaging.

Hope this helps 🙂

FOUND THIS USEFUL? SHARE IT

Tag -

Grails

comments (2)

  1. Rahul

    Thanks for post.
    I’m trying to use this plugin but getting Error “Could not find org.grails.plugins:standalone:9.0.0.M4.”

    can you help to its work?
    Thanks

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *