ClassNotFoundException StrutsPrepareAndExecuteFilter in struts2 [duplicate]

丶灬走出姿态 提交于 2019-11-26 23:35:17

问题


i got this error when starting the app.

SEVERE: Exception starting filter struts2 java.lang.ClassNotFoundException: 
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

and the server gave this error twice in a row.

i have struts2-core-2.3.15.2.jar in WEB-INF/lib and imported into build path.. i do not understand why StrutsPrepareAndExecuteFilter cannot be found.

the application can get started. thats no problem. the problem is because of this error, struts2 cannot redirect the action.

i use tomcat 7 and struts2 2.3.16. cuz it's tomcat 7, the servelet-api is not 3.0 i guess. i tried to put servelet-api-3.0 in tomcat/lib. but it's not compatible.

whats the problem?

Jars used


回答1:


The following minimum jars should be on your classpath:

  • asm-3.3.jar
  • asm-commons-3.3.jar
  • asm-tree-3.3.jar
  • commons-fileupload-1.3.jar
  • commons-io-2.2.jar
  • commons-lang3-3.1.jar
  • commons-logging-1.1.3.jar
  • freemarker-2.3.19.jar
  • javassist-3.11.0.GA.jar
  • log4j-1.2.17.jar
  • ognl-3.0.6.jar
  • struts2-core-2.3.16.jar
  • xwork-core-2.3.16.jar

You can also follow How To Create A Struts 2 Web Application.




回答2:


the runtime problem was solved eventually by replacing the json jars package.. i think its the versions problems. it is a whole package. i dont remember the link now..

so it seems its better get the jar files from one source but not pick different version.. and these 6 jars should be included together. of course, be careful with the versions. i dont know mine. but it works.

commons-lang.jar
commons-logging.jar
commons-beanutils.jar
commons-collections.jar
json-lib-2.2.2-jdk15.jar
ezmorph.jar

BUT this problem is still there... I have this error, but the app can run

java.lang.ClassNotFoundException: 
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter



回答3:


Maybe the jars in WEB-INF/lib aren't copied to WEB-INF/lib of Tomcat. Please see the Deployment assembly property pages, which allow you to add flexible resource and dependency mapping to your applications.




回答4:


If you are using external JRE, it may not work. Instead use the internal JRE (which is inside JDK)

In the project

Go to Build path

-->Configure Build path

-->Libraries

-->Add Libraries

-->Installed JRRs

--> Give path of "JDK"(and not external JRE)

-->Finish.

Refresh the project and it would work.




回答5:


If you use Intellij IDEA, the reason maybe you did not add struts-xxx.xxx.jar file to artifacts.To solve this problem you just need open Project structure >> problems >> add struts x.x.x to artifacts(righit click on the problem option)

It works for me ,may it helps you.



来源:https://stackoverflow.com/questions/23220862/classnotfoundexception-strutsprepareandexecutefilter-in-struts2

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