gpt4 book ai didi

java - Tomcat 7版本不兼容,抛出java.lang.abstractmethoderror

转载 作者:行者123 更新时间:2023-12-01 12:40:12 24 4
gpt4 key购买 nike

实际上,我正在从 Tomcat 5 迁移我的应用程序至Tomcat 7.0.37 。它给了我一个 java.lang.abstractmethoderror exception当我启动服务器时。我正在使用ANT构建我的应用程序。我读过很多帖子并尝试了很多解决方案,但没有一个对我有用。堆栈跟踪是:

org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [jsp] in context with path [] threw exception
[java.lang.AbstractMethodError: javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/ServletContext;)Ljavax/servlet/jsp/JspApplicationContext;] with root cause
java.lang.AbstractMethodError: javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/ServletContext;)Ljavax/servlet/jsp/JspApplicationContext;
at org.apache.jsp.index_jsp._jspInit(index_jsp.java:22)
at org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:49)
at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:171)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:354)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
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:306)
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:161)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:380)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
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:288)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)

这里是ant使用的build.xml文件

<project name="XYZ" default="all" basedir="..">
<property name="build" value="build" />
<property name="parm" value="parm" />
<property name="src" value="src" />
<property name="lib" value="lib" />
<property name="classes" value="classes" />
<property name="jars" value="jars" />
<property name="war" value="war" />

<target name="init">
<!-- Create the time stamp -->
<tstamp />

<condition property="isIncrementalBuild">
<and>
<istrue value="${build.incremental}" />
</and>
</condition>
</target>

<target name="compile" depends="init" description="Compile component sources">
<!--delete dir="WEB-INF/classes/com" quiet="yes" /-->
<javac srcdir="src" verbose="true" debug="true" deprecation="true" destdir="WEB-INF/classes">
<classpath refid="project.classpath" />
</javac>

</target>

<target name="build" depends="compile" description="Build outofmem">
<delete file="war/${webarchive.name}" quiet="no" />
<war destfile="war/${webarchive.name}" webxml="WEB-INF/web.xml" manifest="mf/META-INF/MANIFEST.MF" >
<classes dir="WEB-INF/classes" />
<fileset dir="jsp"/>
<webinf dir="./WEB-INF" includes="**/*" excludes="web.xml, **/*.jar, **/*.class"/>
<lib file="WEB-INF/lib/*.jar" />
</war>
</target>


</project>

最佳答案

经过大量的研发和近四天的工作,我能够从 IDE 中删除错误。问题仅出在类路径(buildpath)上。到处都写着冲突的 jar 或不匹配的 jar &只有两个 jar 可能会导致这种情况。但实际上,有一些与 servlet-api、servlet、jsp-api 和 jasper 相关的 jar 会产生问题。从 buildpath 和 WEB-INF 文件夹中删除它们后。如果您在项目中遇到编译错误,请不要害怕,因为这将由 Apache 的服务器运行时来处理,您将添加到构建路径中以消除编译错误。现在我可以部署我的应用程序并访问服务器。

谢谢

关于java - Tomcat 7版本不兼容,抛出java.lang.abstractmethoderror,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25183297/

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