启动tomcat服务器时,出现异常
SEVERE: Servlet /MavenWeb threw load() exception java.lang.ClassCastException: org.springframework.web.servlet.DispatcherServlet cannot be cast to javax.servlet.Servlet
我正在使用spring3,但是我的lib文件夹中有jar spring2-5-6,我从pom.xml中删除了它,但仍出现在lib文件夹中- 尽管我不确定这是否是问题。我正在使用Eclipse IDE。谢谢!!
<dependencies> <dependency> <groupId>org.hibernate.javax.persistence</groupId> <artifactId>hibernate-jpa-2.1-api</artifactId> <version>1.0.0.Draft-6</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-annotations</artifactId> <version>3.5.6-Final</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>3.1.2.RELEASE</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>3.1.2.RELEASE</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>3.1.2.RELEASE</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>3.1.2.RELEASE</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>3.1.2.RELEASE</version> <scope>compile</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1-b01</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webflow</artifactId> <version>1.0.6</version> <scope>compile</scope> </dependency> </dependencies>
您不应该在一个项目中使用Spring JAR的多个版本,但这不是问题。
该问题很可能是由两个不同的类加载器加载的Servlet API类引起的。可能您servlet*.jar的WAR中有或其他一些特定于容器的JAR。将它们设置<scope>为provided中,以将其删除pom.xml。
servlet*.jar
<scope>
provided
pom.xml