The webapp context will give you access to the WebApp Manifest
ApplicationContext ctx = getContext();
final ServletContext sCtx =
((WebApplicationContext)ctx).getHttpSession().getServletContext();
will give you access to the WebApp context, from which you can retrieve the manifest with the getResourceAsStream routine.
The webapp manifest is the one you should be updating with a version number, and you should be getting it with code as above.
If you search the web, you will find discussions on how the “getResourceAsStream” method differs – there is a version on the Class class, and a version on the ServletContext class, and they don’t quite do the same thing.
I tried this but it seems that Vaadin isn’t using a standart Servlet contexte or maybe I’m wrong
Here is the error message I get
java.lang.ClassCastException: com.vaadin.terminal.gwt.server.ApplicationServlet cannot be cast to javax.servlet.Servlet
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1104)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:806)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Vaadin is using com.vaadin.terminal.gwt.server.WebApplicationContext, which the example referred to.
Note that this is not the same as e.g. WebAppContext of jetty.
This looks like a classloader issue: javax.servlet.Servlet has been loaded with a different classloader than ApplicationServlet (or by two different classloaders), and the JVM does not consider them to be compatible with each other. It is unclear, though, why this occurs here.
Solving this might require some server-specific classpath management.
These classes and interfaces are already provided by the runtime environment (servlet container).
If you don’t otherwise have these on your classpath (from GWT, Jetty, or some other library) when compiling, it might help to tell Maven only to use this dependency at compilation time but not deploy your copy of it for runtime: