Grails on GlassFish v3 - Embedded or Stand-alone
Posted by arungupta on July 30, 2008 at 10:13 AM EDT
Grails 1.0.3 was released a few weeks ago. This blog uses the instructions originally posted here and shows how to deploy a simple Grails application on GlassFish.
- Download Grails 1.0.3 and unzip.
- Download the latest *-overlay.zip from here
and unzip on your Grails installation as shown:
~/tools/grails-1.0.3 >unzip ~/Downloads/grails-gfv3-1.1-overlay.zip
Archive: /Users/arungupta/Downloads/grails-gfv3-1.1-overlay.zip
creating: lib/glassfish-v3/
inflating: lib/glassfish-v3/gf-embedded-api-1.0-alpha-4.jar
inflating: lib/glassfish-v3/web-all-10.0-build-20080430.jar
inflating: lib/grails-gfv3-1.1.jar
inflating: scripts/RunAppGf.groovy - Create a sample app as explained in Getting Started With Grails on GlassFish.
- Run the app using embedded
GlassFish as:
~/tools/grails-1.0.3/samples/helloworld >grails run-app-gf
Welcome to Grails 1.0.3 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /Users/arungupta/tools/grails-1.0.3
Base Directory: /Users/arungupta/tools/grails-1.0.3/samples/helloworld
Note: No plugin scripts found
Running script /Users/arungupta/tools/grails-1.0.3/scripts/RunAppGf.groovy
Environment set to development
Starting GlassFish embedded server... [copy] Copying 1 file to /Users/arungupta/.grails/1.0.3/projects/helloworld
Running Grails application..
Application name : helloworld
Web App Root :/Users/arungupta/tools/grails-1.0.3/samples/helloworld/web-app
web.xml:/Users/arungupta/.grails/1.0.3/projects/helloworld/resources/web.xml
Jul 28, 2008 2:25:38 PM com.sun.enterprise.v3.server.AppServerStartup run
INFO: HK2 initialized in 620 ms
Jul 28, 2008 2:25:38 PM com.sun.enterprise.v3.server.AppServerStartup run
INFO: com.sun.enterprise.naming.impl.ServicesHookup@2aef3499 Init done in 646 ms
Jul 28, 2008 2:25:38 PM com.sun.enterprise.v3.server.AppServerStartup run
INFO: com.sun.enterprise.v3.server.Globals@3710f32d Init done in 648 ms
Jul 28, 2008 2:25:38 PM com.sun.enterprise.v3.server.AppServerStartup run
INFO: com.sun.enterprise.v3.server.SystemTasks@632dc291 Init done in 655 ms
Jul 28, 2008 2:25:38 PM com.sun.enterprise.v3.server.AppServerStartup run
INFO: com.sun.enterprise.v3.services.impl.HouseKeeper@64c3d9c0 Init done in 658 ms
Jul 28, 2008 2:25:38 PM com.sun.enterprise.v3.server.AppServerStartup run
INFO: com.sun.enterprise.v3.services.impl.CmdLineParamProcessor@3a151d3b Init done in 664 ms
JMXMP connector server URL = service:jmx:jmxmp://localhost:8888
Jul 28, 2008 2:25:39 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
INFO: Listening on port 8080
Jul 28, 2008 2:25:39 PM com.sun.enterprise.v3.server.AppServerStartup run
INFO: com.sun.enterprise.v3.services.impl.GrizzlyService@2ddd5c89 startup done in 1059 ms
Jul 28, 2008 2:25:39 PM com.sun.enterprise.v3.services.impl.ApplicationLoaderService postConstruct
INFO: loader service postConstruct started at 1217280339578
Jul 28, 2008 2:25:39 PM com.sun.enterprise.v3.server.AppServerStartup run
INFO: Application Loader startup done in 1353 ms
Jul 28, 2008 2:25:39 PM com.sun.enterprise.v3.server.AppServerStartup run
INFO: Glassfish v3 started in 1355 ms
Jul 28, 2008 2:25:41 PM org.apache.catalina.loader.WebappLoader setClassPath
INFO: Unknown loader org.glassfish.grails.MaskingClassLoader@5cbde5b4 class org.glassfish.grails.MaskingClassLoader
Jul 28, 2008 2:25:41 PM com.sun.enterprise.web.WebModuleContextConfig authenticatorConfig
SEVERE: webModuleContextConfig.missingRealm
[0] spring.GrailsWebApplicationContext Refreshing org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext@4c721585: display name [org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext@4c721585]; startup date [Mon Jul 28 14:25:44 PDT 2008]; parent: org.springframework.web.context.support.XmlWebApplicationContext@631a8160
[0] spring.GrailsWebApplicationContext Bean factory for application context [org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext@4c721585]: org.springframework.beans.factory.support.DefaultListableBeanFactory@3e11bc1d
Server running. Browse to http://localhost:8080/helloworld - Create a controller
~/tools/grails-1.0.3/samples/helloworld >grails create-controller home
Welcome to Grails 1.0.3 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /Users/arungupta/tools/grails-1.0.3
Base Directory: /Users/arungupta/tools/grails-1.0.3/samples/helloworld
Note: No plugin scripts found
Running script /Users/arungupta/tools/grails-1.0.3/scripts/CreateController.groovy
Environment set to development
[copy] Copying 1 file to /Users/arungupta/tools/grails-1.0.3/samples/helloworld/grails-app/controllers
Created Controller for Home
[mkdir] Created dir: /Users/arungupta/tools/grails-1.0.3/samples/helloworld/grails-app/views/home
[copy] Copying 1 file to /Users/arungupta/tools/grails-1.0.3/samples/helloworld/test/integration
Created ControllerTests for Home - Edit the generated controller in
"grails-app/controllers/HomeController.groovy" such that it
looks like:
class HomeController {
def index = {
render "Grails using embedded GlassFish!"
}
} - Refresh the web page in the browser and it looks like:

and clicking on "HomeController" shows the output as:

Browsing to "http://localhost:8080/helloworld" shows:
This application can also be deployed on stand-alone GlassFish v3 Technology Preview 2 as explained here. This blog explains how to configure JNDI resources for a Grails application and I plan to explore that in upcoming days.
Once the Servlet engine in Grails is made configurable then GlassFish can be used as the target deployment platform from "run-app" script.
NetBeans 6.5 M1 provide extensive support on Grails application development - details are available here.
Technorati: grails glassfish v3 embedded netbeans
Related Topics >>
Blog Links >>
- Login or register to post comments
- Printer-friendly version
- arungupta's blog
- 1514 reads






Comments
by arungupta - 2008-07-31 13:09
Luigi, I think you should be able to submit your feedback at: http://developers.sun.com/contact/feedback.jsp?&category=j2me&mailsubjec...by luicap75 - 2008-07-31 10:06
i'm sorry to disturb You. I've a problem with J2ME Wireless Toolkit 2.2 please, can you tell me who can help me? thanks Luigi