Problems When Deploying Working Application on Google App Engine

Google Dev and production environment has differences. You may run into problems if you expect that application will also run fine on app engine if there are no errors on app engine development server. We are in process of porting an existing application on Google App engine. The application we are building uses Wicket, Spring and JPA. If you read the will it play in app engine you will find that Spring is compatible, Jpa works with datanucleus implementation and Wicket is semi compatible.

Most of the work required for porting the application required changes in data layer of the application. You can read more about the way to use jpa for persistence in Google App engine here. Wicket does work with the workarounds mentioned here. For wicket application we need to enable sessions in app engine config file.


Second we need to disable thread monitoring resource watcher.

protected void init() {

and at last we need to override the newSessionStore() to return HttpSession store because the default second level session store uses which Google App Engine does not allow.

protected void newSessionStore() {
	return new HttpSessionStore(this);

After the changes described above for porting the application we were able to successfully run the application on Google App Engine development server. Finally we tried deploying the working application on Google App Engine. It was a different story, to our surprise the application simply failed to start on Google App Engine environment.

First problem we encountered was that our application did not start on Google App Engine after it failed with the trace: “java.lang.NoClassDefFoundError: javax/naming/NamingException”. Some classes in Spring JPA support uses javax.naming.NamingException which is not available in Google App Engine. There is an issue logged here. We are using Spring version 2.5.6 and we used the following workaround. We defined a bean in our application context file.

<bean id="org.springframework.context.annotation.internalPersistenceAnnotationProcessor" class="com.inphina.rrm.GaeFixInternalPersistenceAnnotationProcessor" />

and created a class GaeFixInternalPersistenceAnnotationProcessor.

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class GaeFixInternalPersistenceAnnotationProcessor {

	private static final Logger log = LoggerFactory.getLogger(GaeFixInternalPersistenceAnnotationProcessor.class);

	public GaeFixInternalPersistenceAnnotationProcessor() {"Creating fake internalPersistenceAnnotationProcessor to bypass GAE blacklist problem");



This resolved the error and our application came up to life. But our excitement died out soon the moment we logged in our application. We just encountered our second problem we encountered a trace “java.lang.RuntimeException:$2”.

This problem occurred when we directly used the query results in our Wicket components. The query result returned by the data nucleus implementation is not serializable. As it is evident from the error, we can only use classes that can be Serialized in our wicket components. The work around for this problem was to use an unattached list of objects rather than an attached list. For example if we have a DAO which returns a List of departments in our Wicket component then we have to make sure we create a new List of departments and add all elements of departments returned from the DAO.
Here is the old code

List<Department> departments = departmentDAO.findAll();

after the discussed changes

List<Department> departments = new ArrayList();

We learnt that there are differences in the Google App Engine development server environment and Google App Engine environment. We expected that if an application works fine on Google App Engine development environment then it will do the same on Google App Engine environment. Can it also happen that application runs fine on Google App Engine environment but not so on our development environment? well for now, none that we have encountered. From our experience of porting our application to Google App Engine, the help Google App engine community, we believe that it is a fantastic platform to port our application to and with time it will grow better and better.

This entry was posted in Cloud, Java and tagged , , , , , . Bookmark the permalink.

One Response to Problems When Deploying Working Application on Google App Engine

  1. Pingback: Managing Wicket Serialization Problem On Google App Engine « Inphina Thoughts

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s