New grails-standalone plugin
I noticed a while back looking at open Grails issues that there was an interesting one about running a Grails application as a standalone jar, GRAILS-99. Jenkins has this option and uses Winstone but I wasn’t able to get it completely working with a Grails application. It would start up and serve the index GSP but controller-based actions just showed a blank page. It might have been fixable, but the project hasn’t been updated since 2008 and I didn’t want to invest a lot of time on this so I did it a bit more manually using Tomcat.
I took the same approach as Winstone, i.e. creating a JAR with a Main-class entry in the manifest for a class that extracts an embedded WAR file to a temporary folder and uses a servlet container to host the application. I’m using Tomcat 7.0.16 and borrowed a lot of code from the Tomcat plugin. There’s a Gant script (build-standalone) which builds a WAR (or uses an existing one if specified) and builds the JAR by expanding the five Tomcat jars and adding the WAR and the launcher class.
There are a few configuration options, but the simplest workflow is to run
in your project directory, which creates target/standalone.jar
, and then run
and the application will be running at http://localhost:8080.
The plugin portal page is here, the full docs are here and the source is here. Report issues and suggestions on the User mailing list.
Hi Burt,
Looks like the plugin is pretty old now and buggy. A simple grails application created with 2.0.3 is not running and fails with error:
SEVERE: null
java.lang.NoClassDefFoundError: Could not initialize class org.apache.tomcat.util.http.Cookies
at org.apache.coyote.Request.(Request.java:131)
at org.apache.coyote.AbstractProcessor.(AbstractProcessor.java:44)
at org.apache.coyote.http11.AbstractHttp11Processor.(AbstractHttp11Processor.java:257)
at org.apache.coyote.http11.Http11Processor.(Http11Processor.java:55)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.createProcessor(Http11Protocol.java:161)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.createProcessor(Http11Protocol.java:99)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:549)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:679)
Exception in thread “http-bio-8080-exec-7” java.lang.NullPointerException
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.release(Http11Protocol.java:136)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.release(Http11Protocol.java:99)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:638)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:679)
Hi Burt,
I am a total Git newby. I would like to try the StandAlone plugin. But, since it’s not already setup as a binary that can just be placed in the plugin dependencies, I’m not sure what to do to use it. Is there a place that I can go to get the “published” plugin to install in my Grails app?
Can I just download the zip file, change the name of it to grails-standalone.zip and place it in my local binary repository?
Install by adding the dependency in the plugins section of BuildConfig from the top of http://grails.org/plugin/standalone and see the usage docs here: http://grails-plugins.github.io/grails-standalone/docs/manual/index.html