gpt4 book ai didi

java - Servlet.service() 抛出 ClassCastException

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:45:26 26 4
gpt4 key购买 nike

我有一个 Java 网络应用程序。我已经设置了这个新项目并在运行 jsp 时出现以下异常,

Oct 10, 2012 3:01:49 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.ClassCastException: org.apache.catalina.util.DefaultAnnotationProcessor cannot be cast to org.apache.AnnotationProcessor
at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:151)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:340)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
Oct 10, 2012 3:01:57 AM org.apache.catalina.loader.WebappClassLoader modified
INFO: Additional JARs have been added : 'activation-1.1.jar'
Oct 10, 2012 3:01:57 AM org.apache.catalina.core.StandardContext reload
INFO: Reloading this Context has started
Oct 10, 2012 3:01:57 AM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/AutoUpgrade] registered the JBDC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Oct 10, 2012 3:01:57 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/AutoUpgrade] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak.

我已经多次尝试清理和构建项目,获取最新的 service-api.jar,我的库非常广泛,我无法确定导致此错误的任何 jar 之间是否存在任何不一致。我在 jdk 1.6 上的 Apache Tomcat 6 上运行该项目(我的项目需要在 1.6 上运行)。我试过用谷歌搜索这个异常,但没有得到任何与我的问题相关的帖子。 stackoverflow上的相关问题讲的是NullPointerException。

我认为问题一定出在我的库上,但我无法指出根本原因。

谢谢

最佳答案

当您的 Web 应用程序的 /WEB-INF/lib 中有特定于 Tomcat 的 JAR 文件时,就会发生这种情况。这是不对的。您应该从那里删除所有特定于 servletcontainer 的 JAR 文件。他们根本不属于那里。它们应该已经由 servletcontainer 本身提供。 /WEB-INF/lib 应该只包含特定于 webapp 本身的库,这些库不是由 servletcontainer 提供的。

如果您由于粗心地尝试修复编译错误而将它们放在那里,那么请仔细阅读如何以正确的方式解决它的答案:How do I import the javax.servlet API in my Eclipse project?

关于java - Servlet.service() 抛出 ClassCastException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12814008/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com