Hi everybody,
I’m trying to implement server push using Vaadin 7.2.4 on my embedded Jetty server (9.2.1.v20140609). However, I keep getting exceptions during startup. These are the steps I have already executed:
-
Instructed Maven to load the Vaadin server push stuff:
com.vaadin
vaadin-push
${vaadin.version}
-
Applied a server push annotation to my Vaadin UI:
@Push(PushMode.AUTOMATIC)
public class MyUI extends UI
-
Enabled server push on my embedded Jetty server:
ServletHolder servletHolder = new ServletHolder(servlet);
servletHolder.setInitParameter(“pushmode”, “automatic”);
servletHolder.setAsyncSupported(true);
webAppContext.addServlet(servletHolder, “/*”);
-
In Jetty 9.1 the WebSocketPolicy.setMaxMessageSize method has been removed, which is called by Atmosphere. To avoid the NoSuchMethodException I also added following temporary workaround (see
ticket
):
servletHolder.setInitParameter(“org.atmosphere.cpr.asyncSupport”, “org.atmosphere.container.JSR356AsyncSupport”);
-
In the previous step we told Atmosphere to use Jetty’s to use it’s JSR356 standard Java websocket API, instead of it’s native websocket API (see
blog
). Therefore I added following
dependencies
for Maven:
org.eclipse.jetty.websocket
javax-websocket-server-impl
${jetty.version}
javax.websocket
javax.websocket-api
1.0
-
At this point I get following exception
com.vaadin.server.ServiceException: Atmosphere init failed
at com.vaadin.server.communication.PushRequestHandler.(PushRequestHandler.java:
at com.vaadin.server.VaadinServletService.createRequestHandlers(VaadinServletService.
at com.vaadin.server.VaadinService.init(VaadinService.java:180)
at com.vaadin.server.VaadinServlet.createServletService(VaadinServlet.java:190)
at com.vaadin.server.VaadinServlet.[u]
[color=#0000FF]
init
/color
at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:595)
at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:385)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:862)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1341)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1334)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:744)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:497)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:
at org.eclipse.jetty.server.Server.start(Server.java:357)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.jav
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:60)
at org.eclipse.jetty.server.Server.doStart(Server.java:324)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68when starting up my embedded Jetty:
…
Caused by: java.lang.IllegalStateException:
ServerContainer is null
at org.atmosphere.container.JSR356AsyncSupport.(JSR356AsyncSupport.java:43)
The only information I can find about this exception, is a similar
problem
with Tomcat: "
The attribute is always null when calling ServletContext during the Servlet.init() operation"
. It looks like this is the case in my call stack above. Does anybody know what I’m doing wrong, or how I could workaround this problem?
Thanks a lot!!
Bart Butenaers