1

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?

André Schild
  • 4,592
  • 5
  • 28
  • 42

1 Answers1

1

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

jvalli
  • 721
  • 4
  • 7
  • Thanks for your answer. I removed my test code and started again with this example: https://vaadin.com/book/-/page/advanced.cdi.html - "Communicating Between UIs" . There are no failures but the push doesn´t work as expected. The message i´ve pushed will only be displayed when i refresh the browser (click a navigation point) :(. –  Nov 10 '15 at 08:22
  • You should be able to use polling to refresh the ui regardless of cdi contexts, do you have a copy of your exact codebase somewhere? – jvalli Nov 10 '15 at 08:48
  • It works :). I had have a look on the vaadin push demo. When I add the following piece of code it works: UI.getCurrent().getPushConfiguration().setPushMode(PushMode.AUTOMATIC);. I thought this was the default because I declared this on the servlet. –  Nov 10 '15 at 09:04