Grails on Google App Engine – Part 2: Project Setup
October 17, 2010 at 5:09 pm | Posted in GAE, Grails, Groovy, Java, Web | 4 CommentsTags: App Engine, Big Table, cloud, GAE, GAE/J, Google, Grails, Groovy, JDO
Setting up Grails for App Engine on my favorite IDE IntelliJ was as easy as installing the App Engine plugin. At the time of writing the latest plugin version is 0.8.10. It is by far not free of bugs but gets you where you want. It provides you with the basic setup to build, run and deploy your project in your development environment. The plugin was fully compatible with Grails 1.3.1. I didn’t try out to upgrade my project to the latest version of Grails yet. Stick to the plugin documentation to get the basic setup going. To be able to reference the GAE/J classes I dropped in the JAR files appengine-api-1.0-sdk-1.3.7.jar and jdo2-api-2.3-eb.jar into my project’s lib directory. It was extremely helpful to set up Log4J correctly right away. Earlier versions of the plugin had some Log4J-related bugs but they seem to be fixed now. Here’s an excerpt of my Config.groovy:
log4j = {
appenders {
console name:'stdout', layout:pattern(conversionPattern: '%d{dd MMM yyyy HH:mm:ss,SSS} [%t] %-5p %c{2} - %m%n')
}
debug 'grails.app', 'com.favalike'
...
}
The plugin still has a bug related to i18n. In case you’re using one of the messages.properties files to store internalized texts that would leave these files empty after building the WAR file. I could still make it work by applying the workaround described in the JIRA ticket. You got to change your Bootstrap.groovy as follows and build your WAR file for production environment: grails -Dgrails.env=production app-engine package.
import grails.util.Environment
class BootStrap {
def messageSource
def init = { servletContext ->
if(Environment.getCurrent() == Environment.PRODUCTION) {
messageSource.basenames = ['WEB-INF/grails-app/i18n/messages']
messageSource.clearCache()
}
}
def destroy = {
}
}
To improve performance from the get go I made sure I had precompilation enabled. Furthermore, static files can get served by dedicated servers and caches. Both settings are made in appengine-web.xml.
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
...
<precompilation-enabled>true</precompilation-enabled>
<static-files>
<include path="/favicon.ico" />
<include path="/css/**.css" />
<include path="/images/**.*" />
<include path="/js/**.js" expiration="1d" />
</static-files>
</appengine-web-app>
- Grails on Google App Engine – Part 1: A Case Study
- Grails on Google App Engine – Part 3: Persistence
- Grails on Google App Engine – Part 4: Third-Party Libraries
- Grails on Google App Engine – Part 5: Conclusion
4 Comments »
RSS feed for comments on this post. TrackBack URI
Leave a Reply
Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.

[...] Grails on Google App Engine – Part 2: Project Setup [...]
Pingback by Grails on Google App Engine – Part 1: A Case Study « Global Gateway— October 17, 2010 #
[...] Grails on Google App Engine – Part 2: Project Setup [...]
Pingback by Grails on Google App Engine – Part 3: Persistence « Global Gateway— October 17, 2010 #
[...] Grails on Google App Engine – Part 2: Project Setup [...]
Pingback by Grails on Google App Engine – Part 4: Third-Party Libraries « Global Gateway— October 17, 2010 #
[...] Grails on Google App Engine – Part 2: Project Setup [...]
Pingback by Grails on Google App Engine – Part 5: Conclusion « Global Gateway— October 17, 2010 #