This is the 150th tip published on this blog so decided to make it a collection of all the previous ones. Here is a tag cloud (created from wordle.net/create) from title of all the tips:
As expected GlassFish is the most prominent topic. And then there are several entries on NetBeans, JRuby/Rails, several Java EE 6 technologies like JPA, JAX-WS, JAX-RS, EJB, and JSF, and more entries on Eclipse, OSGi and some other tecnhologies too. Here is a complete collection of all the tips published so far:
- #149: How to clean IntelliJ cache, preferences, etc on Mac OS X ?
- #148: JPA2 Metamodel Classes in NetBeans 7.0 – Writing type-safe Criteria API
- #147: Java Server Faces 2.0 Composite Components using NetBeans – DRY your code
- #146: Understanding the EJB 3.1 Timer service in Java EE 6 – Programmatic, Deployment Descriptor, @Schedule
- #145: CDI Events – a light-weight producer/consumer in Java EE 6
- #144: CDI @Produces for container-managed @Resource
- #143: Retrieve Twitter user timeline using using Jersey and OAuth
- #142: GlassFish 3.1 – SSH Provisioning and Start/Stop instance/cluster on local/remote machines
- #141: Running GlassFish 3.1 on Ubuntu 10.04 AMI on Amazon EC2
- #140: Moving GlassFish Installation – Referenced file does not exist "osgi-main.jar"
- #139: Asynchronous Request Processing using Servlets 3.0 and Java EE 6
- #138: GlassFish 3.1 Milestone 1 – Clustering and Application Versioning Demos
- #137: Asynchronous EJB, a light-weight JMS solution – Feature-rich Java EE 6
- #136: Default Error Page using Servlets 3.0 – Improved productivity using Java EE 6
- #135: JSF2 Composite Components using NetBeans IDE – lightweight Java EE 6
- #134: Interceptors 1.1 in Java EE 6 – What and How ?
- #133: JPA2 (JPQL & Criteria), JavaDB, and embedded GlassFish – perfect recipe for testing
- #132: Servlets 3.0 in Embedded GlassFish Reloaded – lightweight Java EE 6
- #131: Dynamic OSGi services in GlassFish – Using ServiceTracker
- #130: Invoking a OSGi service from a JAX-WS Endpoint – OSGi and Enterprise Java
- #129: Managed Beans 1.0 in Java EE 6 – What and How ?
- #128: EJBContainer.createEJBContainer: Embedded EJB using GlassFish v3
- #127: Embedding GlassFish in an existing OSGi runtime – Eclipse Equinox
- #126: Creating an OSGi bundles using Eclipse and deploying in GlassFish
- #125: Creating an OSGi bundles using NetBeans and deploying in GlassFish
- #124: OSGi Declarative Services in GlassFish – Accessed from a Java EE client
- #124: Using CDI + JPA with JAX-RS and JAX-WS
- #123: f:ajax, Bean Validation for JSF, CDI for JSF and JPA 2.0 Criteria API – all in one Java EE 6 sample application
- #122: Creating a JPA Persistence Unit using NetBeans 6.8
- #121: JDBC resource for MySQL and Oracle sample database in GlassFish v3
- #120: Deployment Descriptor-free Java EE 6 application using JSF 2.0 + EJB 3.1 + Servlets 3.0
- #119: Telnet to GlassFish v3 with NetBeans 6.8 – "Could not open connection to the host"
- #118: Managing OSGi bundles in GlassFish v3 – asadmin, filesystem, telnet console, web browser, REST, osgish
- #117: Invoke a JAX-WS Web service from a Rails app deployed in GlassFish
- #116: GlassFish v3 Administration using JavaFX front-end – JNLP available
- #115: GlassFish in Eclipse – Integrated Bundle, Install Stand-alone or Update Existing plugin
- #114: How to enable Java Console in Mac OS X, Windows, … ?
- #113: JavaFX front-end for GlassFish v3 Administration – Using REST interface
- #112: Exposing Oracle database tables as RESTful entities using JAX-RS, GlassFish, and NetBeans
- #111: Rails Scaffold for a pre-existing table using Oracle and GlassFish
- #110: JRuby on Rails application using Oracle on GlassFish
- #109: How to convert a JSF managed bean to JSR 299 bean (Web Beans) ?
- #108: Java EE 6 web application (JSF 2.0 + JPA 2.0 + EJB 3.1) using Oracle, NetBeans, and GlassFish
- #107: Connect to Oracle database using NetBeans
- #106: How to install Oracle Database 10g on Mac OS X (Intel) ?
- TOTD #105: GlassFish v3 Monitoring – How to monitor a Rails app using asadmin, JavaScript, jConsole, REST ?
- #104: Popular Ruby-on-Rails applications on GlassFish v3 – Redmine, Typo, Substruct
- #103: GlassFish v3 with different OSGi runtimes – Felix, Equinox, and Knoplerfish
- #102: Java EE 6 (Servlet 3.0 and EJB 3.1) wizards in Eclipse
- #101: Applying Servlet 3.0/Java EE 6 “web-fragment.xml” to Lift – Deploy on GlassFish v3
- #100: Getting Started with Scala Lift on GlassFish v3
- #99: Creating a Java EE 6 application using MySQL, JPA 2.0 and Servlet 3.0 with GlassFish Tools Bundle for Eclipse
- #98: Create a Metro JAX-WS Web service using GlassFish Tools Bundle for Eclipse
- #97: GlassFish Plugin with Eclipse 3.5
- #96: GlassFish v3 REST Interface to Monitoring and Management – JSON, XML, and HTML representations
- #95: EJB 3.1 + Java Server Faces 2.0 + JPA 2.0 web application – Getting Started with Java EE 6 using NetBeans 6.8 M1 & GlassFish v3
- #94: A simple Java Server Faces 2.0 + JPA 2.0 application – Getting Started with Java EE 6 using NetBeans 6.8 M1 & GlassFish v3
- #93: Getting Started with Java EE 6 using NetBeans 6.8 M1 & GlassFish v3 – A simple Servlet 3.0 + JPA 2.0 app
- #92: Session Failover for Rails applications running on GlassFish
- #91: Applying Java EE 6 "web-fragment.xml" to Apache Wicket – Deploy on GlassFish v3
- #90: Migrating from Wicket 1.3.x to 1.4 – "Couldn’t load DiskPageStore index from file" error
- #89: How to add pagination to an Apache Wicket application
- #88: How add pagination to Rails – will_paginate
- #87: How to fix the error undefined method `new’ for "Rack::Lock":String caused by Warbler/JRuby-Rack ?
- #86: Getting Started with Apache Wicket on GlassFish
- #85: Getting Started with Django Applications on GlassFish v3
- #84: Using Apache + mod_proxy_balancer to load balance Ruby-on-Rails running on GlassFish
- #83: Eclipse Tools Bundle for GlassFish 1.0 – Now Available!
- #82: Getting Started with Servlet 3.0 and EJB 3.1 in Java EE 6 using NetBeans 6.7
- #81: How to use nginx to load balance a cluster of GlassFish Gem ?
- #80: Sinatra CRUD application using Haml templates with JRuby and GlassFish Gem
- #79: Getting Started with Sinatra applications on JRuby and GlassFish Gem
- #78: GlassFish, EclipseLink, and MySQL efficient pagination using LIMIT
- #77: Running Seam examples with GlassFish
- #76: JRuby 1.2, Rails 2.3, GlassFish Gem 0.9.3, ActiveRecord JDBC Adapter 0.9.1 – can they work together ?
- #75: Getting Started with Grails using GlassFish v3 Embedded
- #74: JRuby and GlassFish Integration Test #5: JRuby 1.2.0 RC2 + Rails 2.x.x + GlassFish + Redmine
- #73: JRuby and GlassFish Integration Test #4: JRuby 1.2.0 RC2 + Rails 2.2.x + GlassFish v2 + Warbler
- #72: JRuby and GlassFish Integration Test #3: JRuby 1.2.0 RC2 + Rails 2.2.x + GlassFish v3
- #71: JRuby and GlassFish Integration Test #2: JRuby 1.2.0 RC1 + Rails 2.2.x + GlassFish v3 Prelude
- #70: JRuby and GlassFish Integration Test# 1: JRuby 1.2.0 RC1 + Rails 2.2.x + GlassFish Gem
- #69: GlassFish High Availability/Clustering using Sun Web Server + Load Balancer Plugin on Windows Vista
- #68: Installing Zones in Open Solaris 2008/11 on Virtual Box
- #67: How to front-end a GlassFish Cluster with Apache + mod_jk on Mac OSX Leopard ?
- #66: GlassFish Eclipse Plugin 1.0.16 – Install v3 Prelude from the IDE
- #65: Windows 7 Beta 1 Build 7000 on Virtual Box: NetBeans + Rails + GlassFish + MySQL
- #64: OpenSolaris 2008/11 using Virtual Box
- #63: jmx4r gem – How to manage/monitor your Rails/Merb applications on JRuby/GlassFish ?
- #62: How to remotely manage/monitor your Rails/Merb applications on JRuby/GlassFish using JMX API ?
- #61: How to locally manage/monitor your Rails/Merb applications on JRuby/GlassFish using JMX ?
- #60: Configure MySQL 6.0.x-alpha to NetBeans 6.5
- #59: How to add Twitter feeds to blogs.sun.com ? + Other Twitter Tools
- #58: Jersey and GlassFish – how to process POST requests ?
- #57: Jersey Client API – simple and easy to use
- #56: Simple RESTful Web service using Jersey and Embeddable GlassFish – Text and JSON output
- #55: How to build GlassFish v3 Gem ?
- #54: Java Server Faces with Eclipse IDE
- #53: Scaffold in Merb using JRuby/GlassFish
- #52: Getting Started with Merb using GlassFish Gem
- #51: Embedding Google Maps in Java Server Faces using GMaps4JSF
- #50: Mojarra 2.0 EDR2 is now available – Try them with GlassFish v3 and NetBeans 6.5
- #49: Converting a JSF 1.2 application to JSF 2.0 – @ManagedBean
- #48: Converting a JSF 1.2 application to JSF 2.0 – Facelets and Ajax
- #47: Getting Started with Mojarra 2.0 nightly on GlassFish v2
- #46: Facelets with Java Server Faces 1.2
- #45: Ajaxifying Java Server Faces using JSF Extensions
- #44: JDBC Connection Pooling for Rails on GlassFish v3
- #43: GlassFish v3 Build Flavors
- #42: Hello JavaServer Faces World with NetBeans and GlassFish
- #41: How I created transparent logo of GlassFish using Gimp ?
- #40: jQuery Autcomplete widget with MySQL, GlassFish, NetBeans
- #39: Prototype/Script.aculo.us Autcomplete widget with MySQL, GlassFish, NetBeans
- #38: Creating a MySQL Persistence Unit using NetBeans IDE
- #37: SQLite3 with Ruby-on-Rails on GlassFish Gem
- #36: Writing First Test for a Rails Application
- #35: Rails Database Connection on Solaris
- #34: Using Felix Shell with GlassFish
- #33: Building GlassFish v3 Workspace
- #32: Rails Deployment on GlassFish v3 from NetBeans IDE
- #31: CRUD Application using Grails – Hosted on GlassFish and MySQL
- #30: CRUD Application using Grails – Hosted on Jetty and HSQLDB
- #29: Enabling "Available Plugins" tab in NetBeans IDE
- #28: Getting Started with Rails 2.0 Scaffold
- #27: Configurable Multiple Ruby Platforms in NetBeans 6.1 M1
- #26: Overriding Database Defaults in Rails 2.0.2
- #25: Rails application with PostgreSQL database using NetBeans
- #24: Getting Started with Rails 2.0.x in JRuby 1.0.3 and JRuby 1.1RC1
- #23: JavaFX Client invoking a Metro endpoint
- #22: Java SE client for a Metro endpoint
- #21: Metro 1.1 with GlassFish v2 UR1 and NetBeans 6
- #20: How to create a new jMaki widget ?
- #19: How to Add Metro Quality-of-Service to Contract-First Endpoint ?
- #18: How to Build The GlassFish v3 Gem for JRuby ?
- #17: Backing Up your Blog Posts on Roller
- #16: Optimizing Metro Stubs by locally packaging the WSDL
- #15: Delete/Update Row from Database using jMaki Data Table
- #14: How to generate JRuby-on-Rails Controller on Windows (#9893)
- #13: Setup Mongrel for JRuby-on-Rails applications on Windows
- #12: Invoking a Java EE 5 Web service endpoint from JRuby
- #11: Setup Mongrel cluster for JRuby-on-Rails applications on Unix
- #10: Consuming JSON and XML representations generated by a Jersey endpoint in a jMaki Table widget
- #9: Using JDBC connection pool/JNDI name from GlassFish in Rails Application
- #8: Generating JSON using JAXB annotations in Jersey
- #7: Switch between JRuby and CRuby interpreter in NetBeans 6
- #6: Difference between Ruby Gem and Rails Plugin
- #5: Loading data from beans in jMaki widgets
- #4: How to convert a Session EJB to a Web service ?
- #3: Using JavaDB with JRuby on Rails
- #2: Change the endpoint address on a pre-generated Web services Stub
- #1: SOAP Messaging Logging in Metro
Just for fun, here is another tag cloud:
You can access all the tips here. And keep those suggestions coming!
Technorati: totd glassfish netbeans jpa jsf jaxws jersey mysql rails osgi eclipse
|
Silicon Valley Code Camp 2009
To the community, By the community, For the community |
Here is the list of GlassFish related sessions:
- Java EE 6 and GlassFish v3: Paving the path for future
- Using Eclipse for Java EE 6 development for the GlassFish™ Application Server
- Dynamic Languages & Web Frameworks in GlassFish
The detailed agenda for each session is explained here.
Here are the coordinates:
Date: Oct 3/4, 2009
Venue: Foothill College, Los Altos, CA
Cost: Free but registration required
Read the trip reports from 2008 and 2007.
With more than a month to go, already 120 sessions have been submitted and 855 attendees registered. The final agenda is not ready yet but typically all Java sessions are on a single day.
It’s a free event, with free coffee, food and lots of networking. What’s there to loose ?
See ya there!
Technorati: siliconvalleycodecamp glassfish javaee6 eclipse
For a change, this blog entry is talking about something that exists for a while now :)
Basically, I wanted to setup a demo environment for Grails and GlassFish v3 Prelude on my machine and so decided to dcument the steps along the process. More detailed steps with explanation are available on GlassFish/Grails Getting Started Wiki.
- Download and unzip GlassFish v3 Prelude.
- Run GlassFish Update Center to install the Grails module as shown:
~/demos/glassfishv3-prelude >./bin/updatetool
The software needed for this command (updatetool) is not installed.
If you choose to install Update Tool, your system will be automatically
configured to periodically check for software updates. If you would like
to configure the tool to not check for updates, you can override the
default behavior via the tool’s Preferences facility.
When this tool interacts with package repositories, some system information
such as your system’s IP address and operating system type and version
is sent to the repository server. For more information please see:
http://wiki.updatecenter.java.net/Wiki.jsp?page=UsageMetricsUC2
Once installation is complete you may re-run this command.
Would you like to install Update Tool now (y/n): y
Install image: /Users/arungupta/demos/glassfishv3-prelude/bin/..
Installing pkg packages.
Installing: [pkg:/[email protected],0-15.1269:20081008T212532Z, pkg:/[email protected],0-15.1269:20081008T212544Z]
Installing updatetool packages.
Installing: [pkg:/[email protected],0-15.1269:20081008T212613Z, pkg:/[email protected],0-15.1269:20081008T212630Z]
Registering notifier: Already registered.
Initialization complete.
Software successfully installed. You may now re-run this command (updatetool).
|
- Now run the Update Center again to see a screen as shown below:
Select “GlassFish support for Grails Framework” and click on “Install” to install the module locally. This creates a new directory “grails” in your GlassFish v3 Prelude directory and install Grails 1.0.4 there.
- Set environment variables as:
~/demos/glassfishv3-prelude/glassfish/grails >export GRAILS_HOME=~/demos/glassfishv3-prelude/glassfish/grails
~/demos/glassfishv3-prelude/glassfish/grails >export PATH=$GRAILS_HOME/bin:$PATH |
- Create a template application as:
~/demos/glassfishv3-prelude/glassfish/grails/samples >grails create-app bookstore
Welcome to Grails 1.0.4 – http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails
Base Directory: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples
Note: No plugin scripts found
Running script /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/scripts/CreateApp.groovy
Environment set to development
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/src
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/src/java
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/src/groovy
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/controllers
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/services
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/domain
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/taglib
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/utils
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/views
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/views/layouts
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/i18n
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/conf
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/test
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/test/unit
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/test/integration
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/scripts
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/web-app
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/web-app/js
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/web-app/css
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/web-app/images
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/web-app/META-INF
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/lib
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/conf/spring
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/conf/hibernate
[propertyfile] Creating new property file: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/application.properties
[copy] Copying 2 files to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore
 
; [copy] Copied 1 empty directory to 1 empty directory under /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore
[copy] Copying 2 files to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/web-app/WEB-INF
[copy] Copying 5 files to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/web-app/WEB-INF/tld
[copy] Copying 28 files to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/web-app
[copy] Copying 18 files to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app
[copy] Copying 1 file to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore
[copy] Copying 1 file to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore
[copy] Copying 1 file to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore
[copy] Copying 1 file to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore
[propertyfile] Updating property file: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/application.properties
Created Grails Application at /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore
|
- Create a domain specific class as:
~/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore >grails create-domain-class book
Welcome to Grails 1.0.4 – http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails
Base Directory: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore
Note: No plugin scripts found
Running script /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/scripts/CreateDomainClass.groovy
Environment set to development
[copy] Copying 1 file to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/domain
Created Domain Class for Book
[copy] Copying 1 file to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/test/integration
Created Tests for Book
|
- Add attributes to the domain class by editing “grails-app/domain/Book.groovy” such that it looks like:
class Book {
String title
String author
} |
- Create a new controller as:
~/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore >grails create-controller Book
Welcome to Grails 1.0.4 – http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails
Base Directory: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore
Note: No plugin scripts found
Running script /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/scripts/CreateController.groovy
Environment set to development
[copy] Copying 1 file to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/controllers
Created Controller for Book
[mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/views/book
[copy] Copying 1 file to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/test/integration
Created ControllerTests for Book
|
- Edit the generated controller in “grails-app/controller/BookController.groovy” to specify scaffold for the domain class. It looks like:
class BookController {
def scaffold = Book
} |
- Run the app as shown below:
~/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore >grails run-app
Welcome to Grails 1.0.4 – http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails
Base Directory: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore
Note: No plugin scripts found
Running script /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/scripts/RunApp.groovy
Environment set to development
Starting GlassFish embedded server… [mkdir] Created dir: /Users/arungupta/.grails/1.0.4/projects/bookstore/classes
[groovyc] Compiling 8 source files to /Users/arungupta/.grails/1.0.4/projects/bookstore/classes
[mkdir] Created dir: /Users/arungupta/.grails/1.0.4/projects/bookstore/resources/grails-app/i18n
[native2ascii] Converting 11 files from /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/i18n to /Users/arungupta/.grails/1.0.4/projects/bookstore/resources/grails-app/i18n
[copy] Copying 1 file to /Users/arungupta/.grails/1.0.4/projects/bookstore/classes
[copy] Copying 1 file to /Users/arungupta/.grails/1.0.4/projects/bookstore/resources
[copy] Copying 1 file to /Users/arungupta/.grails/1.0.4/projects/bookstore
Running Grails application..
Application name : bookstore
Web App Root :/Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/web-app
web.xml:/Users/arungupta/.grails/1.0.4/projects/bookstore/resources/web.xml
Mar 18, 2009 10:19:09 PM CommonClassLoaderManager Skipping creation of CommonClassLoader as there are no libraries available
INFO: urls = []
no resource bundle found for version, using default GlassFish version
Mar 18, 2009 10:19:09 PM AppServerStartup run
INFO: [Thread[GlassFish Kernel Main Thread,5,main]] started
Mar 18, 2009 10:19:09 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
INFO: Listening on port 8080
Mar 18, 2009 10:19:10 PM org.glassfish.admin.mbeanserver.ConnectorStartupService$ConnectorsStarterThread startConnector
INFO: Started JMXConnector, JMXService URL = service:jmx:rmi:///jndi/rmi://192.168.1.145:8686/jmxrmi
Mar 18, 2009 10:19:10 PM com.sun.enterprise.v3.admin.adapter.AdminEndpointDecider setGuiContextRoot
INFO: Admin Console Adapter: context root: /admin
Mar 18, 2009 10:19:10 PM com.sun.enterprise.v3.server.AppServerStartup run
INFO: GlassFish v3 Prelude startup time : Embedded(418ms) st
artup services(887ms) total(1305ms)
Mar 18, 2009 10:19:10 PM com.sun.enterprise.web.WebContainer createHttpListener
INFO: Created HTTP listener http-listener-1 on port 8080
Mar 18, 2009 10:19:10 PM com.sun.enterprise.web.WebContainer createHosts
INFO: Created virtual server server
Mar 18, 2009 10:19:11 PM org.apache.catalina.loader.WebappLoader setClassPath
INFO: Unknown loader org.glassfish.grails.MaskingClassLoader@3b948e75 class org.glassfish.grails.MaskingClassLoader
Mar 18, 2009 10:19:12 PM org.apache.catalina.loader.WebappLoader setClassPath
INFO: Unknown loader org.glassfish.internal.api.DelegatingClassLoader@191fa2af class org.glassfish.internal.api.DelegatingClassLoader
Mar 18, 2009 10:19:12 PM org.apache.catalina.core.ApplicationContext log
INFO: PWC1412: WebModule[/bookstore] ServletContext.log():Set web app root system property: ‘bookstore-development-0.1′ = [/Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/web-app/]
Mar 18, 2009 10:19:12 PM org.apache.catalina.core.ApplicationContext log
INFO: PWC1412: WebModule[/bookstore] ServletContext.log():Initializing log4j from [file:/Users/arungupta/.grails/1.0.4/projects/bookstore/resources/log4j.properties]
Mar 18, 2009 10:19:12 PM org.apache.catalina.core.ApplicationContext log
INFO: PWC1412: WebModule[/bookstore] ServletContext.log():Initializing Spring root WebApplicationContext
[0] spring.GrailsWebApplicationContext Refreshing org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext@430b4506: display name [org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext@430b4506]; startup date [Wed Mar 18 22:19:14 PDT 2009]; parent: org.springframework.web.context.support.XmlWebApplicationContext@6ceb51a8
[0] spring.GrailsWebApplicationContext Bean factory for application context [org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext@430b4506]: org.springframework.beans.factory.support.DefaultListableBeanFactory@1f43243e
Mar 18, 2009 10:19:17 PM org.apache.catalina.core.ApplicationContext log
INFO: PWC1412: WebModule[/bookstore] ServletContext.log():Initializing Spring FrameworkServlet ‘grails’
Mar 18, 2009 10:19:17 PM com.sun.enterprise.web.WebApplication start
INFO: Loading application bookstore at /bookstore
Server running. Browse to http://localhost:8080/bookstore
|
Notice, here GlassFish v3 Embedded Server is used for running the application. It is now accessible at “http://localhost:8080/bookstore” and looks like:
- Clicking on the “BookController” shows:
- Click on “New Book” to add a new book as:
- Each entry can be updated/deleted after clicking on “Create” …
or “Book List” as shown below:
In a matter of few minutes, we created a simple Grails scaffold that runs using GlassFish v3 Embedded Server.
Please leave suggestions on other TOTD (Tip Of The Day) that you’d like to see. A complete archive of all tips is available here.
Technorati: totd glassfish v3 grails embedded prelude
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
|
Browsing to “http://localhost:8080/helloworld” shows:
- 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:
More details about GlassFish embedding in Grails are available here.
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
GlassFish v3 is a modular (OSGi compliant), embeddable (runs in-VM) and extensible (hosts non-Java applications) Application Server. The “extensible” part was demonstrated during JavaOne 2008 by deploying Rails, Grails and Django sample application on GlassFish v3 Technology Preview 2. This blog announces the availability of Rails, Grails and (of course!) Java EE version of the demo code.
The sample application is a simple multi-player game that can be played on Internet and deployed on GlassFish. One of the simplest multi-player game is Tic-Tac-Toe. The complete instructions to checkout, build, deploy and run the sample are available here. The demo can certainly be improved by using the best practices from Rails and Grails and I’ll work on them in next few days.
The demo is played in 2 different browser windows (tested on Firefox, Safari & IE). The clicks in the grid on one browser are displayed on the other browser (propagated using GlassFish Comet) and row and column winners are shown.
Some points highlighted by the demo are:
- GlassFish v3 supports deployment of Rails and Grails applications, in addition to traditional Java EE apps.
- GlassFish v3 has a completely modular architecture as evident by the pluggability of JRuby/Rails.
- Features of the underlying GlassFish runtime can be accessed.
-
- Any click in the grid is pushed to the endpoint and then propagated to all the clients using GlassFish Comet. So effectively, now you can build Comet-enabled applications using Rails and Grails.
- Rails application is deployed as a composite application where Serlvet is bundled with the application and accessed from the View.
Check out the demo now!
You can learn about the support of different Dynamic Languages on GlassFish on glassfish-scripting.dev.java.net. Send us feedback on or GlassFish WebTier Forum.
Technorati: conf javaone javaone08 jruby ruby rubyonrails grails javee glassfish v3 netbeans
TOTD #30 explained how to create CRUD application using Grails and hosted using in-built Jetty servlet engine and in-memory HSQLDB database. Jetty and HSQLDB are built into Grails and allows to start easily. You can also use GlassFish and MySQL for deploying your applications in production environment.
This blog entry walks you through the steps of deploying a Grails application on GlassFish and MySQL.
- If MySQL is already installed, then download GlassFish v2 UR1. Otherwise you can also Download GlassFish v2 UR1 and MySQL co-bundle from usual Download Page (instructions).
- Configure MySQL database
- Download MySQL Connector/J 5.1.6 from here.
- Extract the bundle and copy “mysql-connector-java-5.1.6-bin.jar” to the “lib” directory of Grails application.
- Start MySQL database as:
~/testbed/grails-1.0.2/samples/crud >sudo /usr/local/mysql/bin/mysqld_safe –user root –console
Starting mysqld daemon with databases from /usr/local/mysql/data |
- Create database by giving the following command:
~/testbed/grails-1.0.2/samples/crud >/usr/local/mysql/bin/mysqladmin create crudProd –user root |
- Configure the Application
- Edit “grails-app/conf/DataSource.groovy” to specify MySQL configuration. The updated file looks like (changes highlighted in bold):
dataSource {
pooled = false
driverClassName = “com.mysql.jdbc.Driver“
username = “root“
password = “”
dialect = “org.hibernate.dialect.MySQL5InnoDBDialect”
}
hibernate {
cache.use_second_level_cache=true
cache.use_query_cache=true
cache.provider_class=’org.hibernate.cache.EhCacheProvider’
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = “create-drop” // one of ‘create’, ‘create-drop’,'update’
url = “jdbc:hsqldb:mem:devDB”
}
}
test {
dataSource {
dbCreate = “update”
url = “jdbc:hsqldb:mem:testDb”
}
}
production {
dataSource {
dbCreate = “update”
url = “jdbc:mysql://localhost/crudProd“
}
}
} |
Being in production, it’s recommended to use InnoDB tables instead of MyISAM tables. This can be easily specified by using the dialect as explained here. More details about the contents of “DataSource.groovy” can be found here.
- Create a WAR by giving the following command:
~/testbed/grails-1.0.2/samples/crud >grails war
Welcome to Grails 1.0.2 – http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /Users/arungupta/testbed/grails-1.0.2
Base Directory: /Users/arungupta/testbed/grails-1.0.2/samples/crud
Note: No plugin scripts found
Running script /Users/arungupta/testbed/grails-1.0.2/scripts/War.groovy
Environment set to production
[delete] Deleting: /Users/arungupta/.grails/1.0.2/projects/crud/resources/web.xml
[delete] Deleting directory /Users/arungupta/.grails/1.0.2/projects/crud/classes
. . .
[propertyfile] Updating property file: /Users/arungupta/testbed/grails-1.0.2/samples/crud/staging/WEB-INF/classes/application.properties
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/staging/WEB-INF/plugins
[copy] Warning: /Users/arungupta/testbed/grails-1.0.2/samples/crud/plugins not found.
[jar] Building jar: /Users/arungupta/testbed/grails-1.0.2/samples/crud/crud-0.1.war
[delete] Deleting directory /Users/arungupta/testbed/grails-1.0.2/samples/crud/staging
Done creating WAR /Users/arungupta/testbed/grails-1.0.2/samples/crud/crud-0.1.war
|
- Deploy the WAR file as:
g="2" cellspacing="2">
~/testbed/grails-1.0.2/samples/crud >~/testbed/glassfish/v3/p2b9/glassfish/bin/asadmin deploy crud-0.1.war
crud-0.1 deployed successfully
Command deploy executed successfully. |
The application is now accessible at “http://localhost:8080/crud-0.1″ and looks like:
- READ – Click on “StateController” and the following page is shown:
- CREATE – Click on “New State” and enter the values as shown below:
and click on “Create” to see the following page:
- UPDATE & DELETE – You can click on “Edit” or “Delete” to perform U or D of CRUD or click on “State List” to view the updated list.
Please leave suggestions on other TOTD that you’d like to see. A complete archive is available here.
Technorati: groovy grails glassfish mysql scripting netbeans
After a simple Grails application, let’s create a CRUD application. Such an application allows to perform basic database operations to read table rows from the database, create new rows, and edit and delete existing rows. This blog shows how such an application can be created using Grails, hosted on built-in Jetty servlet engine and use in-memory HSQLDB database for persistence.
A follow-up entry will show how this application can be deployed in production mode on GlassFish and using MySQL database.
- Create a Grails application
- After Grails download and configuration, create a new application “crud” as:
~/testbed/grails-1.0.2/samples >grails create-app crud
Welcome to Grails 1.0.2 – http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /Users/arungupta/testbed/grails-1.0.2
Base Directory: /Users/arungupta/testbed/grails-1.0.2/samples
Note: No plugin scripts found
Running script /Users/arungupta/testbed/grails-1.0.2/scripts/CreateApp.groovy
Environment set to development
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/src
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/src/java
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/src/groovy
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/grails-app
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/grails-app/controllers
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/grails-app/services
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/grails-app/domain
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/grails-app/taglib
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/grails-app/utils
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/grails-app/views
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/grails-app/views/layouts
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/grails-app/i18n
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/grails-app/conf
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/test
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/test/unit
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/test/integration
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/scripts
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/web-app
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/web-app/js
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/web-app/css
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/web-app/images
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/web-app/META-INF
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/lib
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/grails-app/conf/spring
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/grails-app/conf/hibernate
[propertyfile] Creating new property file: /Users/arungupta/testbed/grails-1.0.2/samples/crud/application.properties
[copy] Copying 2 files to /Users/arungupta/testbed/grails-1.0.2/samples/crud
[copy] Copying 2 files to /Users/arungupta/testbed/grails-1.0.2/samples/crud/web-app/WEB-INF
[copy] Copying 5 files to /Users/arungupta/testbed/grails-1.0.2/samples/crud/web-app/WEB-INF/tld
[copy] Copying 87 files to /Users/arungupta/testbed/grails-1.0.2/samples/crud/web-app
[copy] Copying 17 files to /Users/arungupta/testbed/grails-1.0.2/samples/crud/grails-app
[copy] Copying 1 file to /Users/arungupta/testbed/grails-1.0.2/samples/crud
[copy] Copying 1 file to /Users/arungupta/testbed/grails-1.0.2/samples/crud
[copy] Copying 1 file to /Users/arungupta/testbed/grails-1.0.2/samples/crud
[propertyfile] Updating property file: /Users/arungupta/testbed/grails-1.0.2/samples/crud/application.properties
Created Grails Application at /Users/arungupta/testbed/grails-1.0.2/samples/crud
|
- In your project directory, create a domain class as:
~/testbed/grails-1.0.2/samples/crud >grails create-domain-class state
Welcome to Grails 1.0.2 – http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /Users/arungupta/testbed/grails-1.0.2
Base Directory: /Users/arungupta/testbed/grails-1.0.2/samples/crud
Note: No plugin scripts found
Running script /Users/arungupta/testbed/grails-1.0.2/scripts/CreateDomainClass.groovy
Environment set to development
[copy] Copying 1 file to /Users/arungupta/testbed/grails-1.0.2/samples/crud/grails-app/domain
Created for State
[copy] Copying 1 file to /Users/arungupta/testbed/grails-1.0.2/samples/crud/test/integration
Created Tests for State
|
This creates “State.groovy” class in “grails-app/domain” directory and looks like:
Add two fields to store state name and the corresponding abbreviation as shown below:
class State {
String name
String abbrev
} |
- Change “grails-app/conf/BootStrap.groovy” class to initialize the domain with sample data as shown below:
class BootStrap {
def init = { servletContext
->
new State(name:”California”, abbrev:”CA”).save()
new State(name:”New York”, abbrev:”NY”).save()
new State(name:”Texas”, abbrev:”TX”).save()
new State(name:”Wisconsin”, abbrev:”WI”).save()
}
def destroy = {
}
}
|
- Create a new controller as:
~/testbed/grails-1.0.2/samples/crud >grails create-controller state
Welcome to Grails 1.0.2 – http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /Users/arungupta/testbed/grails-1.0.2
Base Directory: /Users/arungupta/testbed/grails-1.0.2/samples/crud
Note: No plugin scripts found
Running script /Users/arungupta/testbed/grails-1.0.2/scripts/CreateController.groovy
Environment set to development
[copy] Copying 1 file to /Users/arungupta/testbed/grails-1.0.2/samples/crud/grails-app/controllers
Created Controller for State
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/crud/grails-app/views/state
[copy] Copying 1 file to /Users/arungupta/testbed/grails-1.0.2/samples/crud/test/integration
Created ControllerTests for State
|
This generates ”grails-app/controllers/StateController.groovy” with the following content:
class StateController {
def index = { }
}
|
Replace it with to define a scaffold:
class StateController {
def scaffold = State
}
|
- Start the application using built-in Jetty Servlet engine and in-memory HSQLDB database as shown below:
~/testbed/grails-1.0.2/samples/crud >grails run-app
Welcome to Grails 1.0.2 – http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /Users/arungupta/testbed/grails-1.0.2
Base Directory: /Users/arungupta/testbed/grails-1.0.2/samples/crud
Note: No plugin scripts found
Running script /Users/arungupta/testbed/grails-1.0.2/scripts/RunApp.groovy
Environment set to development
Running Grails application..
2008-04-18 17:26:29.962::INFO: Logging to STDERR via org.mortbay.log.StdErrLog
2008-04-18 17:26:29.075::INFO: jetty-6.1.4
2008-04-18 17:26:29.155::INFO: No Transaction manager found – if your webapp requires one, please configure one.
2008-04-18 17:26:30.886:/crud:INFO: Set web app root system property: ‘crud’ = [/Users/arungupta/testbed/grails-1.0.2/samples/crud/web-app/]
2008-04-18 17:26:30.886:/crud:INFO: Initializing Log4J from [file:/Users/arungupta/.grails/1.0.2/projects/crud/resources/log4j.properties]
2008-04-18 17:26:30.945:/crud:INFO: Initializing Spring root WebApplicationContext
[0] spring.GrailsWebApplicationContext Refreshing org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext@848dfb: display name [org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext@848dfb]; startup date [Fri Apr 18 17:26:32 PDT 2008]; parent: org.springframework.web.context.support.XmlWebApplicationContext@cddcc3
[1] spring.GrailsWebApplicationContext Bean factory for application context [org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext@848dfb]: org.springframework.beans.factory.support.DefaultListableBeanFactory@11f136
2008-04-18 17:26:34.655:/crud:INFO: Initializing Spring FrameworkServlet ‘grails’
2008-04-18 17:26:35.716::INFO: Started [email protected]:8080
Server running. Browse to http://localhost:8080/crud
|
The application is now accessible at “http://localhost:8080/crud” and looks like:
- READ – Click on “StateController” and the following page is shown:
- CREATE – Click on “New State” and enter the values as shown below:
and click on “Create” to see the following page:
- UPDATE & DELETE – You can click on “Edit” or “Delete” to perform U or D of CRUD or click on “State List” to view the updated list as shown below:
Please leave suggestions on other TOTD that you’d like to see. A complete archive is available here.
Technorati: groovy grails glassfish jetty hsqldb scripting crud
This blog has published good amount of content on how Ruby-on-Rails applications can be deployed on GlassFish. Grails is another popular MVC-based framework that leverages the Groovy language. Basically, Grails : Groovy :: Rails : Ruby.
Starting today, I plan to start publishing content on Grails and talk about how GlassFish v3 is turning out to be a home for several scripting languages – Ruby/JRuby/Rails, JavaScript/Phobos, Groovy/Grails and more to be added.
This blog shows how to get started with Grails and deploy a simple application on GlassFish v3. Lets go!
- Download Grails 1.0.2 (docs, release notes, other builds) and unzip.
~/testbed/grails-1.0.2 >export GRAILS_HOME=`pwd`
~/testbed/grails-1.0.2 >export PATH=$GRAILS_HOME/bin:$PATH |
On MacOS 10.5, I had to manually set the executable permissions using “chmod +x grails” and then saw the following:
~/testbed/grails-1.0.2 >grails
Welcome to Grails 1.0.2 – http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /Users/arungupta/testbed/grails-1.0.2
No script name specified. Use ‘grails help’ for more info
|
- Create & Deploy a Grails HelloWorld:
- Create a Grails app “helloworld” as:
~/testbed/grails-1.0.2/samples >grails create-app helloworld
Welcome to Grails 1.0.2 – http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /Users/arungupta/testbed/grails-1.0.2
Base Directory: /Users/arungupta/testbed/grails-1.0.2/samples
Note: No plugin scripts found
Running script /Users/arungupta/testbed/grails-1.0.2/scripts/CreateApp.groovy
Environment set to development
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/src
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/src/java
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/src/groovy
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/grails-app
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/grails-app/controllers
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/grails-app/services
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/grails-app/domain
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/grails-app/taglib
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/grails-app/utils
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/grails-app/views
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/grails-app/views/layouts
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/grails-app/i18n
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/grails-app/conf
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/test
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/test/unit
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/test/integration
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/scripts
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/web-app
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/web-app/js
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/web-app/css
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/web-app/images
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/web-app/META-INF
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/lib
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/grails-app/conf/spring
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/grails-app/conf/hibernate
[propertyfile] Creating new property file: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/application.properties
[copy] Copying 2 files to /Users/arungupta/testbed/grails-1.0.2/samples/helloworld
[copy] Copying 2 files to /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/web-app/WEB-INF
[copy] Copying 5 files to /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/web-app/WEB-INF/tld
[copy] Copying 87 files to /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/web-app
[copy] Copying 17 files to /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/grails-app
[copy] Copying 1 file to /Users/arungupta/testbed/grails-1.0.2/samples/helloworld
[copy] Copying 1 file to /Users/arungupta/testbed/grails-1.0.2/samples/helloworld
[copy] Copying 1 file to /Users/arungupta/testbed/grails-1.0.2/samples/helloworld
[propertyfile] Updating property file: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/application.properties
Created Grails Application at /Users/arungupta/testbed/grails-1.0.2/samples/helloworld
|
The top-level directory structure is:
total 56
drwxr-xr-x 14 arungupta arungupta 476 Apr 10 10:44 .
drwxr-xr-x 3 arungupta arungupta 102 Apr 10 10:44 ..
-rw-r–r– 1 arungupta arungupta 5911 Apr 10 10:44 .classpath
-rw-r–r– 1 arungupta arungupta 553 Apr 10 10:44 .project
-rw-r–r– 1 arungupta arungupta 115 Apr 10 10:44 application.properties
-rw-r–r– 1 arungupta&nb
sp; arungupta 1464 Apr 10 10:44 build.xml
drwxr-xr-x 10 arungupta arungupta 340 Apr 10 10:44 grails-app
-rw-r–r– 1 arungupta arungupta 1805 Apr 10 10:44 helloworld.launch
-rw-r–r– 1 arungupta arungupta 2287 Apr 10 10:44 helloworld.tmproj
drwxr-xr-x 2 arungupta arungupta 68 Apr 10 10:44 lib
drwxr-xr-x 2 arungupta arungupta 68 Apr 10 10:44 scripts
drwxr-xr-x 4 arungupta arungupta 136 Apr 10 10:44 src
drwxr-xr-x 4 arungupta arungupta 136 Apr 10 10:44 test
drwxr-xr-x 8 arungupta arungupta 272 Apr 10 10:44 web-app |
This directory is created using Convention over Configuation and the purpose of each directory is explained here.
- The app can be started as:
~/testbed/grails-1.0.2/samples/helloworld >grails run-app
Welcome to Grails 1.0.2 – http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /Users/arungupta/testbed/grails-1.0.2
Base Directory: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld
Note: No plugin scripts found
Running script /Users/arungupta/testbed/grails-1.0.2/scripts/RunApp.groovy
Environment set to development
[mkdir] Created dir: /Users/arungupta/.grails/1.0.2/projects/helloworld/classes
[groovyc] Compiling 6 source files to /Users/arungupta/.grails/1.0.2/projects/helloworld/classes
[mkdir] Created dir: /Users/arungupta/.grails/1.0.2/projects/helloworld/resources/grails-app/i18n
[native2ascii] Converting 10 files from /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/grails-app/i18n to /Users/arungupta/.grails/1.0.2/projects/helloworld/resources/grails-app/i18n
[copy] Copying 1 file to /Users/arungupta/.grails/1.0.2/projects/helloworld/classes
[copy] Copying 1 file to /Users/arungupta/.grails/1.0.2/projects/helloworld/resources
[copy] Copying 1 file to /Users/arungupta/.grails/1.0.2/projects/helloworld
Running Grails application..
2008-04-10 10:47:51.501::INFO: Logging to STDERR via org.mortbay.log.StdErrLog
2008-04-10 10:47:51.603::INFO: jetty-6.1.4
2008-04-10 10:47:51.755::INFO: No Transaction manager found – if your webapp requires one, please configure one.
2008-04-10 10:47:52.503:/helloworld:INFO: Set web app root system property: ‘helloworld’ = [/Users/arungupta/testbed/grails-1.0.2/samples/helloworld/web-app/]
2008-04-10 10:47:52.503:/helloworld:INFO: Initializing Log4J from [file:/Users/arungupta/.grails/1.0.2/projects/helloworld/resources/log4j.properties]
2008-04-10 10:47:52.582:/helloworld:INFO: Initializing Spring root WebApplicationContext
[0] spring.GrailsWebApplicationContext Refreshing org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext@dccb42: display name [org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext@dccb42]; startup date [Thu Apr 10 10:47:53 PDT 2008]; parent: org.springframework.web.context.support.XmlWebApplicationContext@188af2
[0] spring.GrailsWebApplicationContext Bean factory for application context [org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext@dccb42]: org.springframework.beans.factory.support.DefaultListableBeanFactory@413ebc
2008-04-10 10:47:55.602:/helloworld:INFO: Initializing Spring FrameworkServlet ‘grails’
2008-04-10 10:47:55.652::INFO: Started [email protected]:8080
Server running. Browse to http://localhost:8080/helloworld
2008-04-10 10:48:15.133:/helloworld:INFO: GSP servlet initialized
|
The output in the browser looks like:
Jetty is used as the development environment server but soon GlassFish v3 can be used, stay tuned on that!
Anyway, the WAR format is used for deployment. Lets see how this app can be easily deployed as a WAR file on GlassFish v3.
- Download GlassFish v3 Preview 2 b08 and unzip.
- Create and Deploy WAR
- GlassFish certainly supports WAR-based deployment of Grails apps but direct deployment (aka native or directory-based deployment) of Grails applications will be supported soon as well. Anyway, for now, create a WAR file of the application as:
~/testbed/grails-1.0.2/samples/helloworld >grails war
Welcome to Grails 1.0.2 – http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /Users/arungupta/testbed/grails-1.0.2
Base Directory: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld
Note: No plugin scripts found
Running script /Users/arungupta/testbed/grails-1.0.2/scripts/War.groovy
Environment set to production
[delete] Deleting: /Users/arungupta/.grails/1.0.2/projects/helloworld/resources/web.xml
[delete] Deleting directory /Users/arungupta/.grails/1.0.2/projects/helloworld/classes
[delete] Deleting directory /Users/arungupta/.grails/1.0.2/projects/helloworld/resources
[mkdir] Created dir: /Users/arungupta/.grails/1.0.2/projects/helloworld/classes
[groovyc] Compiling 6 source files to /Users/arungupta/.grails/1.0.2/projects/helloworld/classes
[mkdir] Created dir: /Users/arungupta/.grails/1.0.2/projects/helloworld/resources/grails-app/i18n
[native2ascii] Converting 10 files from /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/grails-app/i18n to /Users/arungupta/.grails/1.0.2/projects/helloworld/resources/grails-app/i18n
[copy] Copying 1 file to /Users/arungupta/.grails/1.0.2/projects/helloworld/classes
[copy] Copying 1 file to /Users/arungupta/.grails/1.0.2/projects/helloworld/resources
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/staging
[copy] Copying 93 files to /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/staging
[copy] Copied 19 empty directories to 1 empty directory under /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/staging
[copy] Copying 12 files to /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/staging/WEB-INF/grails-app
[copy] Copying 26 files to /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/staging/WEB-INF/classes
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/staging/WEB-INF/spring
[copy] Copying 1 f
ile to /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/staging/WEB-INF/classes
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/staging/WEB-INF/templates/scaffolding
[copy] Copying 6 files to /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/staging/WEB-INF/templates/scaffolding
[copy] Copying 49 files to /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/staging/WEB-INF/lib
[copy] Copying 1 file to /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/staging/WEB-INF
[delete] Deleting: /Users/arungupta/.grails/1.0.2/projects/helloworld/resources/web.xml
[copy] Warning: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/plugins not found.
[propertyfile] Updating property file: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/staging/WEB-INF/classes/application.properties
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/staging/WEB-INF/plugins
[copy] Warning: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/plugins not found.
[jar] Building jar: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/helloworld-0.1.war
[delete] Deleting directory /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/staging
Done creating WAR /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/helloworld-0.1.war
|
The create WAR file is 18,012,069 bytes.
- Start the GlassFish container as:
~/testbed/glassfish/v3/p2-b08/glassfish >bin/startserv –verbose
Apr 10, 2008 11:03:28 AM com.sun.enterprise.admin.launcher.GFLauncherLogger info
INFO: JVM invocation command line:
/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/bin/java
-cp
/Users/arungupta/testbed/glassfish/v3/p2-b08/glassfish/modules/glassfish-10.0-SNAPSHOT.jar
. . .
INFO: Listening on port 8080
Apr 10, 2008 11:03:29 AM com.sun.enterprise.v3.services.impl.GrizzlyEmbeddedHttpConfigurator configureSSL
WARNING: HTTP listener on port: 8181 is secured, but SSL configuration is not found!
Apr 10, 2008 11:03:29 AM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
INFO: Listening on port 8181
Apr 10, 2008 11:03:29 AM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
INFO: Listening on port 4848
Apr 10, 2008 11:03:29 AM com.sun.enterprise.v3.admin.adapter.AdminConsoleAdapter setContextRoot
INFO: Admin Console Adapter: context root: /admin
Apr 10, 2008 11:03:29 AM com.sun.enterprise.v3.server.AppServerStartup run
INFO: com.sun.enterprise.v3.services.impl.GrizzlyService@b24c9a startup done in 681 ms
Apr 10, 2008 11:03:29 AM com.sun.enterprise.v3.services.impl.ApplicationLoaderService postConstruct
INFO: loader service postConstruct started at 1207850609785
Apr 10, 2008 11:03:29 AM com.sun.enterprise.v3.server.AppServerStartup run
INFO: Application Loader startup done in 717 ms
Apr 10, 2008 11:03:29 AM com.sun.enterprise.v3.server.AppServerStartup run
INFO: Glassfish v3 started in 717 ms
Apr 10, 2008 11:03:29 AM com.sun.enterprise.v3.admin.adapter.AdminConsoleAdapter ready
INFO: AdminConsoleAdapter is ready … |
- Deploy the WAR file as:
~/testbed/grails-1.0.2/samples/helloworld >~/testbed/glassfish/v3/p2-b08/glassfish/bin/asadmin deploy helloworld-0.1.war
helloworld-0.1 deployed successfully
properties=(name=helloworld-0.1)
Command deploy executed successfully. |
The output in the browser now looks like:
- Add Controller and Re-deploy
- Create a new controller as:
C~/testbed/grails-1.0.2/samples/helloworld >grails create-controller hello
Welcome to Grails 1.0.2 – http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /Users/arungupta/testbed/grails-1.0.2
Base Directory: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld
Note: No plugin scripts found
Running script /Users/arungupta/testbed/grails-1.0.2/scripts/CreateController.groovy
Environment set to development
[copy] Copying 1 file to /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/grails-app/controllers
Created Controller for Hello
[mkdir] Created dir: /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/grails-app/views/hello
[copy] Copying 1 file to /Users/arungupta/testbed/grails-1.0.2/samples/helloworld/test/integration
Created ControllerTests for Hello
|
and change the controller as shown:
~/testbed/grails-1.0.2/samples/helloworld >vi grails-app/controllers/HelloController.groovy
class HelloController {
def world = {
render “Hello World!”
}
//def index = { }
}
|
- Re-create & re-deploy the WAR as described in bullet # 4. And now “http://localhost:8080/helloworld-0.1″ shows the output as shown:
and clicking on “HelloController” shows the output as:
The same view is also available at “http://localhost:8080/helloworld-0.1/hello/world” as shown below:
So we deployed a simple Grails application as a WAR on GlassFish v3. Here are some tasks that we are working on:
- Deploy Grails app on GlassFish v3 using “grails” command (in development environment)
- Deploy Grails app directly on GlassFish v3 without creating a WAR (in production environment)
- Seamless integration with NetBeans to provide direct development/deployment to GlassFish
And there is much more, stay tuned!
If you have q
uestions, ask them at GlassFish forum or .
Technorati: groovy grails glassfish v3 scripting netbeans