struts1 java.lang.NoSuchMethodError 问题:org.apache.struts.action.ActionForward.setContextRelative(Z)V

问题描述 投票:0回答:1

我正在开发仍然使用 struts 基本 jar 的遗留应用程序,不幸的是,尽管我们可以升级 jar 版本,但我们无法替换这些 jar。

我在 JSP 加载时遇到以下错误...

javax.servlet.ServletException: Servlet execution threw an exception
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:216)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:661)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:425)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:357)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:294)
    at org.apache.jsp.index_jsp._jspService(index_jsp.java:127)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:623)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:466)
    ... 28 more
Caused by: java.lang.NoSuchMethodError: org.apache.struts.action.ActionForward.setContextRelative(Z)V
    at org.apache.struts.actions.ForwardAction.execute(ForwardAction.java:151)
    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:529)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:623)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:209)
    ... 40 more

项目中使用的struts库如下

struts-1.1.jar
struts-core-1.3.10.jar
struts-el-1.3.10.jar
struts-extras-1.3.10.jar
struts-taglib-1.3.10.jar
taglibs-standard-impl-1.2.5.jar

请您提出这里出了什么问题

struts2 struts struts-1
1个回答
0
投票

有很多不同版本的 Struts 库。您只需添加应用程序所需的依赖项。如果您使用 Struts 1.3.0,则仅需要这些依赖项。但如果你两者都有

  • struts-1.1.jar
  • struts-core-1.3.10.jar

在 lib 文件夹中,你会得到一个错误

引起:java.lang.NoSuchMethodError:org.apache.struts.action.ActionForward.setContextRelative(Z)V

查找的方法属于另一个 jar,该方法被省略,因为类

ActionForward
已由类加载器加载。

© www.soinside.com 2019 - 2024. All rights reserved.