Vaadin 7 Servlet ClassCastException

I am trying to move from Vaadin 6 to Vaadin 7.
When I try to open the application url, I get a ClassCastException

SEVERE: Allocate exception for servlet Vaadin Application Servlet java.lang.ClassCastException: com.vaadin.server.VaadinServlet cannot be cast to javax.servlet.Servlet at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1136) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:857) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:136) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) 

I can't figure out what's wrong, because it seems that web.xml is ok. The application servlet mapping is shown below.

  <servlet> <servlet-name>Ohta Application</servlet-name> <servlet-class>com.vaadin.server.VaadinServlet</servlet-class> <init-param> <description> Vaadin UI class to use</description> <param-name>UI</param-name> <param-value>com.ritmsoft.ohta.OhtaUI</param-value> </init-param> <init-param> <param-name>widgetset</param-name> <param-value>com.ritmsoft.ohta.widgetset.OhtaWidgetSet</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>Ohta Application</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Ohta Application</servlet-name> <url-pattern>/VAADIN/*</url-pattern> </servlet-mapping> 

Help me please.

+4
source share
3 answers

Or, if you are using Maven, make your servlet area "exposed" like this:

  <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.0.1</version> <scope>provided</scope> </dependency> 

That way, it will use the version of the servlet container container if it exists, otherwise it will use the one you declare in Maven.

+2
source

The problem is most likely caused by the fact that javax.servlet.Servlet loaded by several class loaders. It usually exists in servlet*.jar . It is possible that the container provides its own version of this jar, and your application provides a different one. Try to remove it in your war.

+1
source

I have the same problem, but only if I try to run the vaadin maven project with the tomcat plugin for eclipse. The dependency for serlet-api is exactly the same as shown above. Snd tehr it makes no difference if I comment on this in full or just part of the field. There is always servlet-api-2.5-6.1.11 in the lib folder. I do not know where this comes from. But assuming there is definitely no javax.servlet-api.jar in the lib folder. And if I copy the war manuelly into the tomapps webapps folder and start if it works fine on the console. I do not understand. Any ideas?

0
source

All Articles