I have a controller which acts as a form controller and a muilt-action controller, so to speak. Basically, there is a main object being edited via the form as well as some "side conversations" conducted via ajax to get/save data that can then be related related to the main object.

I am getting the exception below *intermittently* when the processSubmit/POST method is called. Is there something going on with @SessionAttributes that I don't understand?

I've done some searching/research but am unable to come up with anything. It's especially tricky since the problem rarely shows up. BTW, using Spring 3.1.0. Thanks for any help!

Code:
org.springframework.web.HttpSessionRequiredException: Session attribute 'command' required - not found in session
         at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodInvoker.raiseSessionRequiredException(AnnotationMethodHandlerAdapter.java:771)
         at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveModelAttribute(HandlerMethodInvoker.java:766)
         at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:364)
         at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171)
         at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
         at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
         ...
Code:
@Controller
@SessionAttributes("command")
public class StuffController {

    @Resource
    private SomeService service;
    
    @InitBinder
    public void initBinder(WebDataBinder binder) {
        DateFormat df = new SimpleDateFormat(DATE_PATTERN);
        df.setLenient(false);
        binder.registerCustomEditor(Date.class, new CustomDateEditor(df, true));
    }
    
    /**
     * Called via Ajax. 
     */
    @RequestMapping(value = "/saveNote",  method = RequestMethod.POST)
    public void saveNote(@RequestParam String note, HttpServletResponse response) throws Exception {
        service.saveNote(note);
    }
    
    // ... other misc url mappings called via ajax exist but are not shown (see above for example)
    
    /**
     * Adds reference data to model and returns the view name of the form view. Not using individual
     * @ModelAttribute annotated methods because of the other urls mapped to this controller 
     * (@ModelAttribute methods always execute and those urls don't need this data).
     */
    private String getForm(ModelMap model, StuffCommand cmd) {
        model.addAttribute("owners", service.getOwners(cmd.getOwnerType()));
        return "formView";
    }

    @RequestMapping(value = "/stuff",  method = RequestMethod.GET)
    protected String showForm(@RequestParam(required = false) Long stuffId, ModelMap model) throws Exception{
        StuffCommand cmd = new StuffCommand();
        model.addAttribute("command", cmd);

        if (stuffId != null) {
            Stuff stuff = service.getStuff(stuffId);
            // copy properties to command object here
        }
        
        return getForm(model, cmd);
    }
    
    @RequestMapping(value = "/stuff",  method = RequestMethod.POST)
    protected String processSubmit(@RequestParam(required = false) Long stuffId, @ModelAttribute("command") StuffCommand cmd,
            BindingResult result, ModelMap model, SessionStatus status) throws Exception {
        
        // validate
        new MyValidator().validate(stuffId, cmd, result);
        if (result.hasErrors()) {
            return getForm(model, cmd);
        }
        else {
            Stuff stuff = new Stuff();
            stuff.setStuffId(stuffId);
            // set other properties here
            service.saveStuff(stuff);
            status.setComplete();
            return "redirect:stuffList";            
        }
    }
}