views:

256

answers:

1

My sessions in Google Appengine works in the development environment but not when I deploy it.

I have sessions-enabled set to true in my appengine-web.xml.

Am I missing something here? I had to override the initBinder in my Controller for it to work in appengine because Spring tries to "access the system class loader"

Maybe I should also do something for my problem but I don't know what it is.

My Controller:

package com.springtutorial.controller;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.propertyeditors.StringTrimmerEditor;
import org.springframework.validation.BindException;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;

import com.springtutorial.model.Course;

public class GetCourseController extends SimpleFormController {

    private static final String ADD_VIDEO_TO_CURRENT_LEARNING_ACTIVITY = "video";
    private static final String NEW_REQUEST = "";
    private static final String ADD_LEARNING_ACTIVITY = "add learning activity";
    private String currentRequest;
    private int activityNumber;

    GetCourseController(){
     setCommandClass(Course.class);
     setCommandName("course");
     setSessionForm(true);
    }

    @Override
    protected ModelAndView showForm(HttpServletRequest request,
      HttpServletResponse response, BindException errors)
      throws Exception {
     if (ADD_LEARNING_ACTIVITY.equals(currentRequest)){
      request.setAttribute("request","add learning activity");
      request.setAttribute("activityNumber",activityNumber);
      activityNumber++;
     } else if (ADD_VIDEO_TO_CURRENT_LEARNING_ACTIVITY.equals(currentRequest)){

     }
     else {
      request.setAttribute("request","new");
     }
     return super.showForm(request, response, errors);
    }
    @Override
    protected boolean isFormChangeRequest(HttpServletRequest request) {
     String action = request.getParameter("submit");
     if (ADD_LEARNING_ACTIVITY.equals(action)){
      currentRequest = ADD_LEARNING_ACTIVITY;
      return true;
     } 
     return false;
    }
    @Override
    protected ModelAndView onSubmit(HttpServletRequest request,
      HttpServletResponse response, Object command, BindException errors)
      throws Exception {
     currentRequest=NEW_REQUEST;
     return super.onSubmit(request, response, command, errors);
    }
    @Override
    protected void initBinder(HttpServletRequest request,
      ServletRequestDataBinder binder) throws Exception {
     binder.registerCustomEditor(String.class, new StringTrimmerEditor(false)); 
    }
A: 

I got this to work by implementing serializable in all my command class. I checked the logs and I was getting the NotSerializableException.

Jeune