GlassFish(tm) Support For Grails Framework

Overview
Grails aims to bring the "coding by convention" paradigm to Groovy. It's an open-source web application framework that leverages the Groovy language and complements Java Web development. You can use Grails as a standalone development environment that hides all configuration details or integrate your Java business logic. Grails aims to make development as simple as possible and hence should appeal to a wide range of developers not just those from the Java community.

GlassFish Support For Grails adds Grails framework to GlassFish application server and allows development and easy deployment of Grails applications. Applications can be deployed in shared or standalone mode. Shared mode allows library reuse and results in much smaller war files. It also provides run-app-gf command to develope the grails applications using GlassFish. This module contains Grails binary distribution, and additional scripts and modules.

Install & Setup

To get started follow these steps:
  • create a GRAILS_HOME environment variable that points to the path of the Grails distribution (the folder contain this file).
  • add the bin folder in the Grails distribution to the PATH environment variable
  • (Optional) If you want to use "shared" setup, use install target in build.xml
On a Windows computer these step are done as follows:
       > set GRAILS_HOME=C:\GlassFish\modules\grails
       > set PATH=%GRAILS_HOME%\bin;%PATH%

       (optional - for "shared libraries" setup)
       >  cd %GRAILS_HOME%
       >  ant install

       
On a Unix-like computer these steps are done as follows:
       > set GRAILS_HOME=~/glassfish/modules/grails
       > export GRAILS_HOME
       > cd $GRAILS_HOME
       > set PATH=$GRAILS_HOME/bin:$PATH
       > export PATH
       > chmod a+x $GRAILS_HOME/bin/*
       
       (optional - for "shared libraries" setup)
       >  cd $GRAILS_HOME
       >  ant install
       
You can now run the grails command:
       > grails create-app YourProject
       
For more info look at the support links below.

Deployment On GlassFish

Developing your applications with GlassFish

Grails GlassFish bundle comes with run-app-gf command. To run your grails application all you need to do is

  1. Go to the application directory, such as
    cd grails/samples/BookLibrary
  2. grails run-app-gf

How to deploy on standalone GlassFish v3

Grails recommends creating a war file using grails war command to package your application for production uses and testing. The GlassFish grails bundle provides grails shared-war command in addition to grails-war. shared-ward command won't package all the grails dependency in a single war file, instead you can run ant install to install the grails libraries on GlassFish v3 (described in the Install and Setup section and save system resources arising from all-in-one war file.

  1. Go to the application directory, such as
    cd grails/samples/BookLibrary
  2. Package the application
    grails war
    For shared libraries:
    grails shared-war
  3. Start glassfish domain (if not already started)
    ~/GlassFish/bin/asadmin start-domain
  4. Deploy the war file to GlassFish
    ~/GlassFish/bin/asadmin deploy BookLibrary-0.1.war
  5. Access the application at
    http://localhost:8080/BookLibrary-1.0/

Documentation

 Community Forum and Resources
     Wiki: GlassFish Groovy/Grails Wiki
     Email: users@glassfish.dev.java.net, user@grails.codehaus.org
     Forum: GlassFish Discussion Forums
     Tools Support:NetBeans Groovy Wiki
     Blogs:Vivek Pandey, Aquarium
     Feature Request: Issue Tracker