Tuesday, April 28, 2009

Experiences with AppEngine

Well, I was quite excited to get my Java early look request accepted. I'm publishing an application soon (I'll write about it later). After the initial success with the "hello world" application I soon had to face some problems.

At my first test project, I started to work with JPA. The list of unsupported features in the docs didn't scare me much. But then found more. First of all, for Id generation, only Identity generation type is supported, but that's a minor issue. A bigger problem was that I could not persist multiple entities in one EntityManager session. This might have been solved by some configuration on Datanucleus, with which I am not familiar, and which I did not start to search for. Finally I just did not manage to persist an associated entity. I got exceptions stating that the parent entity is already persisted with another Id, however the parent entity class mentioned by the exception was actually the child entity. Anyone more familiar with Datanucleus can surely get further.

Then I started to use the JDO framework. I soon ran into the exception mentioned also here, but as there said, it just got resolved at some point, I don't know why.

I had the most problems with my web framework. I'm using an own experimental Direct Ajax framework, called Daam, which is originally designed to work integrated with JBoss Seam, but with some modifications it could be used in the AppEngine environment. A serious thing to consider was that I really have to store all my application information manually in the http session context, and I guess I cannot assume that the same servlet instance will handle all requests of a session. These things are handled by JBoss Seam in the original architecture.

The problems came when I deployed in online. First of all, java.lang.reflect.Method is not serializable, but the deserialization of some objects can be unsuccessful. The exception is similar to the one mentioned in the issue 1290, but I had it with any Object [] or String [] arrays.

Nested in javax.servlet.ServletException: [Ljava.lang.String;:
java.lang.ArrayStoreException: [Ljava.lang.String;
 at java.io.ObjectInputStream.readArray(Unknown Source)
       [...]
       at com.google.apphosting.runtime.jetty.SessionManager.deserialize(SessionManager.java:358)

It also seems that SimpleDateFormat also contains arrays. I had to turn my array fields into Lists and I had to declare my DateFormat fields transient and reinitiate them on need. Later I also found this post. That's it for now, I hope it will help some.