Google App Engine

From Documentation

Get Your App Engine Account Ready

First, you have to sign up an App Engine account and download the App Engine SDK. Refer to the official website for details.

To use Google App Engine for Java, you have to take one additional step: sign up here.

Configure Your App Engine Project

Here we assume you created a App Engine project. If not, please refer here.

There are three files that you have to configure: web.xml, zk.xml and appengine-web.xml. They all reside in the WEB-INF directory.

The web.xml File

The content is similar to other ZK application except the AU engine has to be mapped to /zkau, too (in additions to /zkau/*. Otherwise, AU requests won't be sent to the AU engine. Here is is an example.

<web-app xmlns="" version="2.5">
		<description>ZK listener for session cleanup</description>


The zk.xml File

Google App Engine is a cloud service, so you have to enable the clustering: disable event threads and use serializable UI factory. In addition, Google App Engine doesn't allow users to create a working thread, so we have to disable the resend mechanism.

Here is an example.

	<!-- clustering environment -->

	<!-- GAE doesn't allow user's thread -->

The appengine-web.xml File

App Engine requires one addition configuration file named appengine-web.xml. It resides in the WEB-INF directory.


	<exclude path="/**.zul"/>
	<exclude path="/**.zhtml"/>
	<include path="/**.zul"/>
	<include path="/**.zhtml"/>

More Information

Due to the way App Engine serializes sessions, you have to use ZK 3.6.2 or later. In additions, there are some other limitations.

  • You cannot define functions in zscript, since BeanShell's method can not be serialized correctly[1].
  • You cannot use captcha due to the limit support of AWT[2]

  1. It runs correctly locally but not if uploaded.
  2. You will see a warning, ... Component captcha ignored., in the application log.

Session Memory Limitation

GAE limits the session memory to 1 mega bytes. If a user visits several pages (with different URLs) in the same browser session, there would be several desktops created and stored in the session, and it might run out the 1 mega bytes. To avoid this, you can implement DesktopInit to remove other desktops in the desktop cache. For example,

public class MyDesktopInit implements DesktopInit {
  public void init(Desktop desktop, Object req) throws Exception {    
    HttpServletRequest request = (HttpServletRequest) req;     
    //Remove old Desktop   
    String oldDesktopId = (String) request.getSession().getAttribute("currentDesktopId");   
    WebAppCtrl ctrl = (WebAppCtrl)Executions.getCurrent().getDesktop().getWebApp();   
    DesktopCache dc = ctrl.getDesktopCache(desktop.getSession());   
    //Add new Desktop
    request.getSession().setAttribute("currentDesktopId", desktop.getId()); 


Download a sample application named zk-gae.

You can visit it at

See Also

From forum

Composers on Google AppEngine?

Version History

Version Date Content

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.