NoSuchMethodError when using submitting form in Struts 2

早过忘川 提交于 2021-02-11 12:50:34

问题


I'm currently working through the tutorial found on the Apache Struts2 website.

Currently, whenever I press submit on the form, or when I click the Bruce Philips hyperlink, I get a NoSuchMethodError.

javax.servlet.ServletException: Filter execution threw an exception
root cause

java.lang.NoSuchMethodError: ognl.SimpleNode.isEvalChain(Lognl/OgnlContext;)Z
    com.opensymphony.xwork2.ognl.OgnlUtil.isEvalExpression(OgnlUtil.java:224)
    com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:215)
    com.opensymphony.xwork2.ognl.OgnlValueStack.trySetValue(OgnlValueStack.java:187)
    com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:174)
    com.opensymphony.xwork2.ognl.OgnlValueStack.setParameter(OgnlValueStack.java:152)
        ....

I'm not too sure what the issue is either and I believe I've included everything the tutorial states. I've tried including the dependency in my pom.xml, but that makes no difference either.

<?xml version="1.0" encoding="UTF-8"?>
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>Struts2PracticeSite</groupId>
  <artifactId>Struts2PracticeSite</artifactId>
    <packaging>war</packaging>
  <version>0.0.1</version>
    <build>
        <finalName>Struts2PracticeSite</finalName>
    </build>
    <dependencies>
    <dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-core</artifactId>
    <version>2.3.8</version>
</dependency>

<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.14</version>
</dependency>
</dependencies>


</project>

Any ideas on how I would fix this problem?


回答1:


struts2.3.1.1 allows ognl3.0.2.jar + ognl3.0.2-source.jar + ognl3.0.1 at the same time . struts2.3.1.2 can only have ognl3.0.4, but remove other versions

ognl3.0.4 is a must and can be the only ognl jar!




回答2:


Remove ognl as a dependency as this is already a transient dependency of struts 2.3.8 itself and make sure if Eclipse properly deployed your applications, there are many problems with that.




回答3:


Problem found... Turns out my server version is too old to handle struts 2. I was previously using Geronimo version 2.0.2, and it now runs fine on GlassFish 3.1.2.




回答4:


Use these Jar Combinations for Struts 2 application

enter image description here




回答5:


I believe the dependencies you need

  <dependency>
     <groupId>org.apache.struts</groupId>
     <artifactId>struts2-core</artifactId>
     <version>${struts2.version}</version>
  </dependency>
  <dependency>
     <groupId>org.apache.struts</groupId>
     <artifactId>struts2-tiles-plugin</artifactId>
     <version>${struts2.version}</version>
  </dependency>

there are also other dependencies but these are necessary for Struts2 Tiles application.



来源:https://stackoverflow.com/questions/15138843/nosuchmethoderror-when-using-submitting-form-in-struts-2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!