Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
 _______  .___ _______        ____.  _____   
 \      \ |   |\      \      |    | /  _  \  
 /   |   \|   |/   |   \     |    |/  /_\  \ 
/    |    \   /    |    \/\__|    /    |    \
\____|__  /___\____|__  /\________\____|__  /
     web\/framework   \/                  \/ 

Google App Engine support for Ninja

This module allows to use Ninja on the GAE easily.

In particular it provides:

  • Objectify to store data.
  • The default Mailer.
  • Everything else is absolutely standard Ninja.


ninja-appengine is released along with the GAE SDK. Therefore we use the same version. For instance ninja-appengine 1.9.88 uses SDK 1.9.88.

Usage is straight forward. The most important thing you have to keep in mind is to annotate your controller classes with @FilterWith(AppEngineFilter.class)

public class MyController {

If you cannot use @FilterWith because you are developing a library you can also use annotation @AppEngineEnvironment on classes or methods. But you should prefer using @FilterWith.

This is needed to setup the dev environment. If you forget this you'll get a lot of strange error messages especially in tests.

When using persistence you have to register your objectify models. Please refer to Of Service for some best practises.

In Ninja's context it is best to create a Guice Provider. That we you are able to inject Objectify into your classes. We usually put the class under conf.ObjectifyProvider:

public class ObjectifyProvider implements Provider<Objectify> {

    static {

    public Objectify get() {
        return ObjectifyService.ofy();


You then have to bind your Provider in your conf.Module class:

public class Module extends AbstractModule {

    protected void configure() {

        // bind your Objectify.class to your provider like so:

        install(new AppEngineModule());        



More about Objectify:

Quick start

Generate a Ninja Appengine archetype by calling the following command:

mvn archetype:generate -DarchetypeGroupId=org.ninjaframework -DarchetypeArtifactId=ninja-appengine-blog-archetype

This will generate a full archetype showing a simple blog complete with Objectify as persistence layer. A nice archetype to start your own projects...


Is as easy as:

mvn clean appengine:update -Pupdate


Use the devserver of GAE:

mvn appengine:devserver -Pdevserver


When your tests extend NinjaTest you can just start right away. Initialization of the test env is done via the filter you used for your controllers. The tests use an in-memory implementation of the datastore.

Basic Setup

First of all have a look at the demo application at:

The demo application show best how to setup

  • pom.xml
  • application.conf
  • appengine-web.xml


  1. Add the dependency to your pom:

    org.ninjaframework ninja-appengine-module 1.9.88
  2. Add profiles for production / development to your pom:

The easiest way is to go to

and copy the relevant parts to your project. In short you have to:

  • Have profiles for "update", "devserver" and "jetty-dev".
  • Configure the appengine libraries with the correct scopes
  • Set the build output dir consistently

It is also important to filter the resources to finally set the mode dev / production:



The Appengine xml is pretty default. The only difference is that we are setting the Ninja mode via a system property. Now the whole process inside the pom.xml makes more sense I guess :) ${ninja.mode} is simply the variable getting exchanged with "prod" in case of the update profile and "dev" else...

<appengine-web-app xmlns="">


        <include path="/static/**" />


    <!-- will be set to "prod" when running mvn with profile update -->
    <!-- eg: mvn install appengine:update -Pupdate -->
        <property name="ninja.mode" value="${ninja.mode}" />


Special configuration variables in application.conf

(If you are using the default Ninja AppEngine archetype there is nothing you have to set up)

  • cache.implementation=ninja.appengine.AppEngineCacheImpl Tells Ninja to use the GAE built in cache.
  • postoffice.implementation=ninja.appengine.AppEnginePostofficeImpl Tells Ninja to use GAE to send mails.


Google App Engine support for Ninja Framework







No packages published