ClassNotFoundException StrutsPrepareAndExecuteFilter in struts2 [duplicate]
Asked Answered
M

4

1

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. 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.

What's the problem?

Jars used:

enter image description here

Millennium answered 22/4, 2014 at 13:19 Comment(6)
It's either not being found or you're missing a dependency. You'll need to make sure you're deploying what you think you are.Bayern
@Roman C, i have more jars. just didnt list all of them here. too many. the problem is only about this jar i think, cuz StrutsPrepareAndExecuteFilter is only from struts2-core-2.3.15.2.jar.Millennium
@DaveNewton , what do u mean?Millennium
yes, more jars, more compilations, build the war file and deploy it to the server, look at the apps package of the struts distro. The minimum jars are in the struts basic demo app...Purpure
@RomanC , of course i have more jars. it's not about others. i dont use maven.Millennium
@Millennium You should, or something similar; managing transitive dependencies by hand is a bad idea.Bayern
P
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.

Purpure answered 22/4, 2014 at 14:51 Comment(20)
i have all of them. this is not my first struts2 project. it was working fine until today. i just replaced all the jars with the ones from struts-2.3.16.1 package. it is still the same.Millennium
See also this question.Purpure
@Millennium are you sure you have replaced all of them? and you don't have fileupload jar in your class path. Netbeans provide a clean and build feature. there must be something similar in eclipse too. try if it works after that.Houseclean
i dont need the features from fileupload jar. and i didnt use it either before. it was no problem...Millennium
i'm not sure it should be included or not but all the tutorials says that this jar should be included. further the default interceptor stack uses file upload interceptor.Houseclean
@RomanC can you throw some light here?? ^Houseclean
@Houseclean ok, i included the fileupload jar. but its still the same..Millennium
@Millennium have you re-bulit your project?Houseclean
@Houseclean what do u mean re-build? i cleaned the server and project and deployed again. the application can get started. thats no problem. the problem is because of this error, struts2 cannot redirect the action.Millennium
i don't get it. whats the exact problem? your question says that dispatcher is not found. you have mention that you are using struts 2.3.15.2 but the image you posted shows 2.3.16.1. don't say u have both of them in your classpath.Houseclean
@Houseclean commons-fileupload is the default implementation used for file uploading when maultipart requests are precessed.Purpure
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.Millennium
@ maxx777 of course not both. i just replaced the jars with the latest ones in struts2 2.3.16. but nothing betterMillennium
@Millennium you should check which servlet and jsp apis your server support and use those versions, struts require servlet 2.4 but tomcat 7 supports servlet 3.0 (at least my version 7.0.35)Purpure
@Roman C , i doubt that. i am using the original servlet-api downloaded with tomcat 7.0.52. i also tried replacing the servlet-api in my tomcat 7 with servlet-api-3.0, but the application even could not get started..Millennium
@Roman C , hwo to check which servlet and jsp apis the server supports and uses those versions?Millennium
Now, I see looking to the picture of your lib folder that you have commons-lang3-3.3.2.jar and commons-io.jar unknown version. This is a problem, struts 2.3.15.2 doesn't support these jars. To know the version look inside the jar file manifest.mf or pom.xml.Purpure
it was working well last week...Millennium
Do you understand the meaning of the words "work" and "support"? It might work but if you updated some jars it became not working. Use the correct jars and correct versions that is supported by the struts2 correct release.Purpure
it has nothing to do with commons-lang3-3.3.2.jar and commons-io.jar. no change.Millennium
M
0

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
Millennium answered 23/4, 2014 at 15:33 Comment(0)
D
0

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.

Doloroso answered 14/9, 2016 at 15:30 Comment(0)
P
-1

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.

Pyrrho answered 13/5, 2015 at 5:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.