3

希望这将是这个 Spring MVC 新手的最后一个问题。当我尝试在 Tomcat 7.0 上调用 Spring 3.2 MVC Web 应用程序的首页时,我在控制台中收到 HTTP 错误 500,并出现以下错误。

控制台错误:

SEVERE: Servlet.service() for servlet [jcbulboard] in context with path [/jcbulboard] threw exception [Unable to initialize TldLocationsCache: org.apache.tomcat.util.scan.StandardJarScanner cannot be cast to org.apache.tomcat.JarScanner] with root cause
java.lang.ClassCastException: org.apache.tomcat.util.scan.StandardJarScanner cannot be cast to org.apache.tomcat.JarScanner
    at org.apache.jasper.compiler.JarScannerFactory.getJarScanner(JarScannerFactory.java:39)
    at org.apache.jasper.compiler.TldLocationsCache.init(TldLocationsCache.java:222)
    at org.apache.jasper.compiler.TldLocationsCache.getLocation(TldLocationsCache.java:184)
    at org.apache.jasper.JspCompilationContext.getTldLocation(JspCompilationContext.java:607)
    at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:409)
    at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:475)
    at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1427)
    at org.apache.jasper.compiler.Parser.parse(Parser.java:138)
    at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:242)
    at org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)
    at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
    at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
    at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
    at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1265)
    at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1016)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:965)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:859)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:883)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:781)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
    xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>Job Connections Bulletin Board</display-name>

    <servlet>
        <servlet-name>jcbulboard</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>jcbulboard</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>Welcome.jsp</welcome-file>
    </welcome-file-list>
</web-app>

jcbulboard-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

    <context:annotation-config />

    <context:component-scan base-package="com" />

    <mvc:annotation-driven />

    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="suffix">
            <value>.jsp</value>
        </property>
    </bean>
</beans>

Tomcat罐子:

annotations-api.jar
catalina-ant.jar
catalina-ha.jar
catalina-tribes.jar
catalina.jar
ecj-3.7.2.jar
el-api.jar
jasper-el.jar
jasper.jar
jsp-api.jar
servlet-api.jar
tomcat-api.jar
tomcat-coyote.jar
tomcat-dbcp.jar
tomcat-i18n-es.jar
tomcat-i18n-fr.jar
tomcat-i18n-ja.jar
tomcat-jdbc.jar
tomcat-util.jar
4

2 回答 2

3

通过从我的 lib 和类路径中删除 Tomcat 文件解决了问题,因为 Tomcat 已经包含它们。感谢 DwB 的建议。

于 2013-03-14T15:52:53.340 回答
1

我相信这是一个图书馆问题。我发现这篇文章可能会提供一种方法来确定违规类的加载位置。

于 2013-03-14T12:11:33.413 回答