Wednesday April 23, 2008
TOTD #31: CRUD Application using Grails - Hosted on GlassFish and MySQL
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.
| ~/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 |
| ~/testbed/grails-1.0.2/samples/crud >/usr/local/mysql/bin/mysqladmin create crudProd --user root |
| 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" } } } |
| ~/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 |
| ~/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. |




Please leave suggestions on other TOTD that you'd like to see. A complete archive is available here.
Posted by Arun Gupta in web2.0 | Comments[4]
|
|
|
|
|
Today's Page Hits: 4717
Total # blog entries: 994
| « November 2009 | ||||||
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
1 | 2 | 4 | 6 | 7 | ||
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | |||||
| Today | ||||||
hi,
Talking about production mode:
* you don't want to use "pooled=false"
* you maybe want to use a jndi data source
Thus I' m using something like:
production {
dataSource {
jndiName="java:comp/env/jdbc/crudProd"
}
}
Sadly you then have to update web.xml, and the glassfish deployment descriptors, too.
Posted by Bernhard on April 24, 2008 at 01:51 AM PDT #
@Bernhard: Thanks for the tip! I'm sure I missed some other guidelines for Grails deployment. This blog is merely intended to show hooks with GlassFish & MySQL.
Posted by Arun Gupta on April 24, 2008 at 12:58 PM PDT #
How about showing a Grails CRUD application with two related tables? Example: Users and Address tables, related by address_id or similar.
Posted by Kevin Slater on April 25, 2008 at 05:37 AM PDT #
thanks for the tips however I think this is a little more thani can get into.
Posted by VA Refinance on April 25, 2008 at 07:38 PM PDT #