SpringServletContainerInitializer cannot be cast to javax.servlet.ServletContainerInitializer

Solution 1:

A better servlet 3.0 api dependency entry in pom is available here - https://github.com/SpringSource/greenhouse/tree/servlet3, you should also mark the scope as provided, otherwise the jar will be included in your final war which will interfere with the jar provided by the container which is what seems to be happening in your case.

Solution 2:

I had a similar problem without Spring, where mvn tomcat7:run did not work, despite the servlet deploying to OpenShift just fine. As per Biju Kunjummen's answer, the problem for me was which servlet-api I was compiling against.

Broken:

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

Fixed:

<dependency>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>servlet-api</artifactId>
    <version>3.0.20100224</version>
    <scope>provided</scope>
</dependency>

Not terribly sure why, but it works now.