Grails aims to bring the "coding by convention" paradigm to Groovy. It's an open-source web application framework that leverage 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 command to develop the grails applications using GlassFish. Install & Setup
- Install Grails package using the updatetool from your GLASSFISH_INSTALL/bin/updatetool. See the image below that shows Grails package. After install is finished, Grails package will be instaled at GLASSFISH_INSTALL/glassfish/grails
Cannot resolve external resource into attachment.
- Set GRAILS_HOME environment variable and set PATH to include GRAILS_HOME/bin
- 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
On a Windows computer these step are done as follows:
> set GRAILS_HOME=C:\GlassFish\grails
> set PATH=%GRAILS_HOME%\bin;%PATH%
On a Unix-like computer these steps are done as follows:
> set GRAILS_HOME=~/glassfish/grails
> export GRAILS_HOME
> cd $GRAILS_HOME
> set PATH=$GRAILS_HOME/bin:$PATH
> export PATH
> chmod a+x $GRAILS_HOME/bin/*
Create Grails application You can now run the grails command:
> grails create-app BookLibrary
For more details on developing Grails application refer to Grails QuickStart and Grails UserGuide. Deployment On GlassFish Developing your Grails applications with GlassFish To run your grails application all you need to do is
- Go to the application directory, such as
This will start GlassFish v3 in embedded mode and deploy the application. You can keep editing your grails applications and refresh the application page in the browser to see the changes without restarting the application. Cannot resolve external resource into attachment. ... Cannot resolve external resource into attachment. 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 all-in one WAR file packages around 49 jars and creates a large WAR file. The GlassFish Grails IPS package that you installed using updatetool, provides grails shared-war command in addition to grails war. shared-war command won't package all the grails dependency in a single war file and saves system resources arising from all-in-one war file. The WAR file created using shared-war is quite small couple hudred KBs compared to about 20 MB. Here is how you would deploy a shared WAR and all in one WAR.
- Start glassfish domain (if not already started)
~/GlassFish/bin/asadmin start-domain
- Go to the application directory, such as
- Package and deploy the application
- Lighter, efficient WAR
- Package a smaller, ligther WAR
~/GlassFish/bin/asadmin deploy --libraries $GRAILS_HOME/lib/glassfish-grails.jar BookLibrary-0.1.war
Above, you tell GlassFish where the glassfish-grails.jar is. This jar file provides all the grails jars dependencies in it's MANIFEST files. This allows GlassFish to resolve classes required during grails application deployment.
-
- All in One WAR
- Package all in one (results in to a large) WAR
~/GlassFish/bin/asadmin deploy BookLibrary-0.1.war
- Access the application at
http://localhost:8080/BookLibrary-1.0/
References
|