Vaadin and session scoped Spring beans


I integrated Spring framework into a Vaadin application using Option 3 from document (Application and other components are created as session scoped Spring beans).

I have a problem with ?restartApplication URL command (probably AbstractApplicationServlet.closeApplication method respectively) and Application.close() method as these methods are not invalidating sessions but only unregistering Vaadin Application from it. This works for Applications instances, but it keeps Spring session scoped beans in chaos - because HttpSession is left intact, Spring beans are not recreated but reused.

How can we solve this? I don’t know if there is a simple way how to invalidate all session scoped Spring beans in an application context, maybe just invalidating HttpSession would be simplier?

I tried calling:


in Application.close() method as mentioned in this forum post:, but it throws an Exception:

java.lang.IllegalStateException: invalidate: Session already invalidated

Pavel Arnost

Any luck with this issue?

Instead of ?restartApplication in URL, I have used logout() method as mentioned in second referenced post, it works well.

The logout() method is doable but it would be nice to be able to use the ?restartApplication and/or ?closeApplication.

There should be a hook to support closing a session (or not if desired) on close/restart. I tried to invalidate the session on Application.close() and on AbstractApplicationServlet.getNewApplicationand both result in internal vaadin failures similar to what is described above because it expects the session to be valid.

From Vaadin 6.7.6

    private void closeApplication(Application application, HttpSession session) {
        if (application == null) {

        application.close();   <- invalidating session here cause problems ahead
        if (session != null) {
            WebApplicationContext context = getApplicationContext(session);

Here’s what happens when invaliding session on AbstractApplicationServlet.getNewApplicationand

11:50:58,072 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web]
qm.PqmApplication$Servlet]] (http-- Servlet.service() for servlet com.textura.web.pqm.PqmApplication$Se
rvlet threw exception: java.lang.NullPointerException
        at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.getExistingApplication(AbstractApplicationServlet.j
ava:2220) [vaadin-6.7.6.jar:6.7.6]

        at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.findApplicationInstance(AbstractApplicationServlet.
java:769) [vaadin-6.7.6.jar:6.7.6]

        at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service( [vaadi
        at javax.servlet.http.HttpServlet.service( [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.