Spring Session Scope Bean and Background Thread

Hello Vaadin Fans,

Im facing strange problem right now. Let me describe my problem:

I’ve integrated Vaadin with Spring. I use singletons and session scope beans. Everything works like a charm until I try to use session scope bean in new thread. It ends up with exception:
Caused by: java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.

Important parts of my web.xml:


My Servlet Code:

    private WebApplicationContext appCtx;
    private Class<? extends Application> appClass;
    private String appBean;

    public void init(ServletConfig servletConfig) throws ServletException {
        appBean = servletConfig.getInitParameter("application");
        if(appBean == null){
            throw new ServletException("The application parameter is missing");
        appCtx = WebApplicationContextUtils.getWebApplicationContext(
        appClass = (Class<? extends Application>) appCtx.getType(appBean);
    protected Application getNewApplication(HttpServletRequest request) throws ServletException {
        return appCtx.getBean(appBean, Application.class);

    protected Class<? extends Application> getApplicationClass() throws ClassNotFoundException {
        return appClass;

Thank you in advance for any pointer in that strange case.

Regards, Satrix

This is probably because an vaadin application is not managed by the spring dispatcher and your session scoped bean does not share the same context as your vaadin app

Any idea how to do it without Dispatcher Servlet ?

I dont think it is possible out of the box.

Running a vaadin application via the spring dispatcher servlet would be a nice feature.

Ok. Thank you very much Danny.

Btw. Still waiting for another idea’s :grin: