Vaadin CDI, Push, Long Polling, HTTP Session

Hello,

I am writing a Vaadin UI, which requires push updates from worker threads. But also some of the click handlers require access to the request/response pair (e.g., shiro logout for deleting the remember me cookie, at the moment I cannot log out when a user choose “remember me”. It already was quite difficult to get login working this way in a click handler by capturing security managers at attach() time).

I am deploying on a TomEE 1.6.0.2, and as far as I have researched so far, especially the family of spplication servers based on Tomcat 7 are not able to connect the overall HTTP session to the websocket communication.

Also I need to use CDI for connecting to the back end, especially I am making use of managed thread pools for handling data streaming.

So what I have read is, that when switching the push transport from websockets to long polling, that the click handlers will abain have access to the HTTP session onformation?

So I am currently trying to configure a CDIUI to use long polling instead of websockets:

When I do the code below, I still get a lot of exceptions:
|29.06.14|21:49:36|ERROR |IApplicationServlet]| 185|Servlet.service() for servlet [org.openconjurer.collaboratorium.ui.CollaboratoriumUI$CollaboratoriumUIApplicationServlet]
in context with path threw exception [com.vaadin.server.ServiceException: java.lang.IllegalStateException: Not supported.]
with root cause|
java.lang.IllegalStateException: Not supported.
at org.apache.catalina.connector.Request.startAsync(Request.java:1658)
at org.apache.catalina.connector.RequestFacade.startAsync(RequestFacade.java:1029)

Basically I have three questions:

  1. Are my base assumptions about HTTP session correct? Will that be available normally? Can I use getCurrent() ,ethods and CDI once I swictch to long polling?
  2. Any idea how to activate asyncSupported with CDIUI correctly?
  3. Are there alternative solutions for my base problem?

Thank you very much.

Best regards,
Dominic

@Push(transport = Transport.LONG_POLLING)
@CDIUI(value = "")
public class MyUI extends UI {

[...]


    @SuppressWarnings("serial")
    @WebServlet(asyncSupported = true, urlPatterns = { "/*", "/VAADIN/*" }, initParams = {
            @WebInitParam(name = VaadinSession.UI_PARAMETER, value = "mypackage.MyUI"),
            @WebInitParam(name = Constants.SERVLET_PARAMETER_UI_PROVIDER, value = "com.vaadin.cdi.CDIUIProvider"),
            @WebInitParam(name = Constants.SERVLET_PARAMETER_PRODUCTION_MODE, value = "true"),
            @WebInitParam(name = Constants.SERVLET_PARAMETER_PUSH_MODE, value = "automatic") })
    public static class CollaboratoriumUIApplicationServlet extends
            VaadinServlet {
    }