Vaadin Push - ContextNotActiveException

340 Views Asked by At

I´m using Vaadin 7.5.8 on Wildfly 9.0.2. In our application we need Push support, so I´ve added the maven dependency

<groupId>com.vaadin</groupId>
<artifactId>vaadin-push</artifactId>

and added PushMode Parameter to servlet initialization.

@WebServlet(value = {"/ui/*", "/VAADIN/*"}, asyncSupported = true, initParams = {
@WebInitParam(name = "UIProvider", value = "com.vaadin.cdi.CDIUIProvider"),
@WebInitParam(name = "pushmode", value = "automatic")})

On application start i will see the login page of our application. From this point each action that causes a server communication end with this error:

Caused by: javax.enterprise.context.ContextNotActiveException: WebBeans context with scope type annotation @SessionScoped does not exist within current thread
    at org.apache.webbeans.container.BeanManagerImpl.getContext(BeanManagerImpl.java:330) ~[openwebbeans-impl-1.2.7.jar:1.2.7]
    at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.getContextualInstance(NormalScopedBeanInterceptorHandler.java:88) ~[openwebbeans-impl-1.2.7.jar:1.2.7]
    at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.get(NormalScopedBeanInterceptorHandler.java:70) ~[openwebbeans-impl-1.2.7.jar:1.2.7]
    at com.vaadin.cdi.internal.BeanStoreContainer$$OwbNormalScopeProxy0.getUIBeanStore(com/vaadin/cdi/internal/BeanStoreContainer.java) ~[na:1.0.3]
    at com.vaadin.cdi.internal.UIScopedContext.get(UIScopedContext.java:97) ~[vaadin-cdi-1.0.0.alpha2.jar:1.0.3]
    at org.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.java:754) ~[openwebbeans-impl-1.2.7.jar:1.2.7]
    at org.apache.webbeans.inject.instance.InstanceImpl.get(InstanceImpl.java:139) ~[openwebbeans-impl-1.2.7.jar:1.2.7]

Everything works fine, when i remove the push parameter from the servlet configuration. Is there something wrong with my push configuration?

1

There are 1 best solutions below

3
On

your problem is likely caused by the VaadinUI attempting an asynchronous push to the client while the session context is not active. Try switching to async-supported false to use polling rather than true async push.

This is a limitation of the Vaadin CDI plugin unfortunately, the async push wasn't designed with scope implementations in mind.

-Juuso