Friday, April 10, 2009

 

First thoughts on GAE/Java

Google App Engine has been around for over a year now. It didn't have so big impact on me at first since the only language you could implement your application was python and I don't speak it natively. After the Google Java announcement few days ago I was fast enough to grab myself one of the first 10k test accounts. I have since learned a great deal about some new (for me) and nice technologies and I have to say that I am actually excited about web application development again.

The Eclipse plugin that was released at the same time is one of the biggest things that helped me to get a rapid start on Google App Engine. The plugin contains all required components for App Engine Development and also GWT development so after you install the plugin you can immediately start developing applications for Google App Engine. No need to install any additional software or SDKs. Writing the regular HelloWorld type of applications is easy as Google was kind enough to provide nice documentation on their web site. After you have the application running on local development environment you can launch it at Google cloud with a single mouse click from your Eclipse IDE.

One of the nicest things (IMO) in the application deployment process in general is the possibility to deploy several versions of your application. You can simultaneously access different versions (they're all accessible behind different hostnames). Accessing the versions from special urls before making them public makes testing and functional verification of the application an enjoyable experience. When you are satisfied with a new version you can make it the default one that is then accessible to normal site visitors. Also If you notice a glitch in application some point later you can very easily "roll back" to some earlier version if you like. (I Wish I had have this kind of deployment mechanism in place at some customer sites).

Google App Engine does not support storing data in filesystem. The way to persist data is to store it in google Big Table. From Java that is easily done with JDO or JPA. I tried the JDO way (for the first time in my life) and it was actually a very pleasant experience. The only thing you need to do (in simplest case) to persist your domain objects is to annotate them with JDO annotations - one annotation per class and one annotation per persistent property. After that you just call makePersistent method from PersistenceManager and you data is safe. Again one nice feature of Google App Engine is that you can browse and query the persisted data from the Dashboard application. Also you can manually insert data through the Dashboard application.

As part of my learning new things process I decided to take some recent java application framework, implement a small application with it and deploy it to Google App Engine. The Framework of my choice was Apache Click. There was only two minor issues I had to go though the get it up and running on Google App Engine. First one was to exclude the velocity templates from being served as static resources (in appengine-web.xml):


<static-files>
<exclude path="**.htm" />
</static-files>


Another issue was related to Ognl library (a library that is used by Apache Click to copy properties from Click Forms to domain objects (that can then be persisted with JDO). After setting the Security Manager of OgnlRuntime to null it started to work properly. In Click there is one fancy feature that would allow application extensions packaged as jars to provide static content to webapp that will unfortunately not work as it relies on using the filesystem.

Overall I have to say it was really much fun to work With Google App Engine and I think that it is a very nice platform to build/run your applications. Also the starting costs are definitely not too high. You can store up to 500 MB of data and serve up to 5 million pageloads per month for free! That is more than enough for majority of web sites.

Now if you only could offer your home grown Google App Engine applications in some market place similar to what they have in place for Android. The applications would be installable with single mouse click and running them in small scale would be very affordable or free. I bet this kind of commercial environment would be very interesting for application builders too.

Labels: ,



Comments



I was tinkering with GAE with the new Java-support and googled how to use Velocity templates and ended up here. Never heard of Apache Click before, but it seems to suit my needs and preference extremely well. Thanks for sharing!
# posted by Blogger defdac : April 11, 2009 at 11:02 PM  



Same here - first time I saw Click, but I liked what I saw.
# posted by Blogger Sami Siren : April 14, 2009 at 7:42 AM  



I was wondering if you had any more information on the process you used to deploy a Click application on GAE. I've understood the bit about velocity templates, but I am still confused about the Ognl library and security manager issue. Thanks for the informative post, and good recommendation of Click.
# posted by Blogger Michael : May 15, 2009 at 9:14 AM  



In my naive test code I extended the ClickServlet and added a static code block that set the security manager null:

package fi.foofactory.gae;

import ognl.OgnlRuntime;

import org.apache.click.ClickServlet;

public class TweakedClickServlet extends ClickServlet {
static {
OgnlRuntime.setSecurityManager(null);
}

}

then I configured the web app to use that instead of the default click servlet in web.xml:
<servlet>
<servlet-name>ClickServlet</servlet-name>
<servlet-class>fi.foofactory.gae.TweakedClickServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>

Hope this helps.
# posted by Blogger Sami Siren : May 18, 2009 at 9:06 PM  



Hi Sami,

Thanks for sharing this. Following your advice I got my first Click app working within minutes.

Regarding the static resources packaged in jars, I created Click QuickStart app and deployed it to Tomcat which copies these resources to the 'web/click/*' folder. I then copied the '/click/*' content to my Google App project under the 'war' folder.

The final issue I have is with uploading files and pictures. Click uses Commons FileUpload that spools to disk, which GAE doesn't allow. I think one will have to write an in memory FileItem implementation to get around this.

Anyway thanks again.

kind regards

bob
# posted by Blogger Bob Schellink : June 17, 2009 at 10:55 PM  

Post a Comment

Subscribe to Post Comments [Atom]



<< Home

Navigation