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

时间:2014-08-07 13:03:45

标签: java jsp servlets tomcat7 abstract-methods

实际上我正在将我的应用从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>

1 个答案:

答案 0 :(得分:1)

经过大量的R&amp; D并且工作了将近四天后,我能够从IDE中删除错误。问题出在classpath(buildpath)上。到处都写着相互矛盾的罐子或不匹配的罐子和罐头。只有两罐可以导致这种情况。但实际上有一些与servlet-api,servlet,jsp-api和jasper相关的jar会产生问题。从buildpath和WEB-INF文件夹中删除它们之后。 如果您在项目中遇到编译错误,请不要害怕,因为您将在构建路径中添加的Apache服务器运行时将注意这一点,以便消除编译错误。现在我能够部署我的应用程序并点击服务器。

谢谢