【发布时间】:2012-09-16 20:00:36
【问题描述】:
当我尝试启动我的应用程序时,控制台会显示下一个堆栈跟踪:
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
我读过同样的问题,但是没有 spring-web jars,但是在我的 pom.xml 中我已经包含了 spring 依赖项,问题仍然存在:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
这里是 web.xml 文件(只是为了确定):
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/context/webContext.xml
</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>springServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>springServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
我清理了..,清理了 tomcat 工作目录......,我用 project->clean.. 清理了工作区,但没有任何帮助.. 我非常绝望......
更新============= 经过一些操作和魔术:)我成功地没有出现这样的异常,但出现了下一个:
java.lang.ClassCastException: org.springframework.web.filter.DelegatingFilterProxy cannot be cast to javax.servlet.Filter
【问题讨论】:
-
听起来您正试图从 Eclipse 中运行?不是100%确定。如果是,请打开运行配置并查看您尝试部署到的服务器的“参数”选项卡。这将告诉部署的位置。它通常在 .../.metadata/somewhere.... 去那里,查看 catalina.out 和 localhost.todaydate.log 的“logs”目录,看看报告了哪些错误。
-
是的,我正在使用 Eclipse。我没有发现任何日志。我在许多文件夹中寻找它们,但没有结果:(
-
必须添加一个“答案”来告诉您如何启用它 - 抱歉,我之前忘记了详细信息。尝试一下,看看是否有任何错误。
-
john,我昨天遇到了一个非常相似的问题,并在 stackoverflow.com/questions/10046654/… 上发布了一些提示
标签: java spring spring-mvc spring-security web.xml