Vaadin and AppEngine, I can't get it to work


I’m starting with Vaadin, which has been great so far. Very easy to use, with great results. We’re looking at using it for internal apps mainly although I would like to use it for some more public-facing things, hence…

I’ve been trying to get something working on Google AppEngine and am having trouble, so could do with some help.

Here is my application.

public class MyApplication extends Application implements Button.ClickListener {
    private static final Logger LOG = Logger.getLogger(MyApplication.class.getName());

    private VerticalLayout layout;
    private SampleForm sampleForm;

    public MyApplication() {

    public void init() {
        Window window = new Window();

        sampleForm = new SampleForm();
        layout = new VerticalLayout();




    private void addShowButton() {
        Button b = new Button("Show");
        b.setDescription("Click to show");

    public void buttonClick(Button.ClickEvent event) {
        if (!sampleForm.isValid()) {
            layout.getWindow().showNotification("Sample Form Doesn't validate");
        } else {
            String customerID = sampleForm.getCustomerID();
            layout.getWindow().showNotification("Sample Form shows " + customerID);
        }"Form has value <" + sampleForm.getCustomerID() + "> for customer id");

    private static class SampleForm extends Form {
        private static final String CUSTOMER_ID = "CustomerID";
        private static final String DEFAULT_CAPTION = "Basic Data";

        public SampleForm() {
            getLayout().setMargin(true, true, true, true);
            addField(CUSTOMER_ID, customerIDField());


        public String getCustomerID() {
            return (String) getItemProperty(CUSTOMER_ID).getValue();

        private TextField customerIDField() {
            TextField val = new TextField(CUSTOMER_ID);
            val.addValidator(new RegexpValidator("\\s*\\d+-3-\\d+\\s*", true,
                    "Customer ID is of the form customerID-3-index"));
            return val;

This works fine on my local machine, but doesn’t work at all on AppEngine.

Its up on to look at.

If you type “58-3-5” into the field and hit show it should validate, but doesn’t. If you hit refresh the field state is lost and you see sync errors.

AppEngine is very aggressive at activating and passivating sessions so perhaps its a serialization issue? I put some code in to check and it seemed to serialize/deserialize the application object on every request.

I’ve put the project code at I’m using Guice but I got the same problems when i removed it so don’t think that is the problem.

Any help would be gratefully received, as this has stopped me stone dead.


You need to use GAEApplicationServlet when running in Google App Engine. From what I saw you currently extend AbstractApplicationServlet.

That’s done the trick, thanks. I completely missed the different servlet…