My last article about simple Grails application showed, that for quick development Grails are one of top choices. Inspired by some folks writing all around the web, that Grails plus GAE are even faster web-development solutions, I’ve decided to give it a try. And that’s where troubles came up.
Google App-Engine is quite a new platform for developing projects. Originally, it was Python only, now Java is also available. Since Grails uses standard servlet container, it can be easily deployed on JVM based architecture provided by GAE. Sounds simple and easy, doesn’t it?
Before we can start using app-engine plugin for Grails, let’s make sure that we have Grails version 1.1.1. Unfortunately, the latest release of Grails (1.2-M2) is not compatible with GAE. That is quite a surprise and the reason of my haedache. I tried for an hour to deploy some apps on GAE, but with no result. Twitter Client from my last article was a perfect shot for testing Grails on Google platform. Of course, not only for the sake of tests, but also for showing results of Grails development. Finally, I gave up, because GAE support for some functionalities is still too poor or buggy.
First – download latest Google App-Engine SDK and unpack it somewhere on your disk. When done – set up enviromental path for APPENGINE_HOME, like it’s done here (for Windows):
And that’s it!
Install Grails plugin
It’s time to create your Grails application. Make sure, that app name is very unique because it must be the same on GAE. Create it either by command line or with your IDE. With the first option type in command line:
, then enter newly created projects’ folder and type:
When it comes to IDE – and I’m using NetBeans – we simply create New Groovy project, right-click on it, select ‘Grails Plugins’ and choose app-engine from the list.
Let’s try this simplified way of creating application only for a quick testing GAE and Grails:
With these two lines above we create domain class in our WhateverName application. App-Engine requires packaged domain classes for some reason. The second command generates for us whole the rest – controllers and views, what means we have an application ready to go. Ah, sorry – for GAE we still need a little bit more:
App-Engine requires quite strict version numeration, so it won’t accept numbers like 0.1.
First of all, we need account on Google App-Engine If you have Google account it is enough to login. Than we have to create application with our WhateverName (should be exact match).
Back to our command line; let’s prepare war for our app:
Now we can deploy it on GAE platform:
This command works for Windows with folder paths specified as above. And if no errors occure we will be able to see progress of deploying. We will be asked for our Google email and password too. After finished deployment our application can be found under the adress http://WhateverName.appspot.com. All of that sounds easy, but believe me, I’ve had hard time trying to figure out what causes errors, blank pages, etc.
- no java threads
- no writing to filesystem
- no JDBC support
- you can create only 10 apps, but they cannot be deleted
- the latest Grails not supported
It’s a real pain to develop more complicated Grails applications on Google App-Engine. Still GAE is a decent solution for many projects, since it’s free (up to some limits). Still buggy and annoying, but seriously: App-Engine has been supporting Java for like three months and Grails app-engine plug-in is even younger, so I’m pretty sure some problems will be solved soon. I’m quite curious about other users experiences with Grails and App-Engine.
So please share your experiences and troubles with us. And stay tuned.