How to configure struts2 in Eclipse: classnotfoundexception: org... Dispatcher. Ng. Filter. strutsprepareandexecutefil

Source: Internet
Author: User

In the beginning, I configured user libraries (Struts-2.2.3 for multiple projects) according to a textbook ), then introduce Struts-2.2.3 directly (this package will not be placed in the project folder ):

However, the program cannot be started due to an error as shown in the following figure:

Severe: exception starting filter struts2
Java. Lang. classnotfoundexception: org. Apache. struts2.dispatcher. Ng. Filter. strutsprepareandexecutefilter
At org. Apache. Catalina. loader. webappclassloader. loadclass (webappclassloader. Java: 1680)
At org. Apache. Catalina. loader. webappclassloader. loadclass (webappclassloader. Java: 1526)
At org. Apache. Catalina. Core. applicationfilterconfig. getfilter (applicationfilterconfig. Java: 269)
At org. Apache. Catalina. Core. applicationfilterconfig. setfilterdef (applicationfilterconfig. Java: 422)
At org. Apache. Catalina. Core. applicationfilterconfig. <init> (applicationfilterconfig. Java: 115)
At org. Apache. Catalina. Core. standardcontext. filterstart (standardcontext. Java: 4071)
At org. Apache. Catalina. Core. standardcontext. Start (standardcontext. Java: 4725)
At org. Apache. Catalina. Core. containerbase. Start (containerbase. Java: 1053)
At org. Apache. Catalina. Core. standardhost. Start (standardhost. Java: 840)
At org. Apache. Catalina. Core. containerbase. Start (containerbase. Java: 1053)
At org. Apache. Catalina. Core. standardengine. Start (standardengine. Java: 463)
At org. Apache. Catalina. Core. standardservice. Start (standardservice. Java: 525)
At org. Apache. Catalina. Core. standardserver. Start (standardserver. Java: 754)
At org. Apache. Catalina. startup. Catalina. Start (Catalina. Java: 595)
At sun. Reflect. nativemethodaccessorimpl. invoke0 (native method)
At sun. Reflect. nativemethodaccessorimpl. Invoke (nativemethodaccessorimpl. Java: 39)
At sun. Reflect. delegatingmethodaccessorimpl. Invoke (delegatingmethodaccessorimpl. Java: 25)
At java. Lang. Reflect. method. Invoke (method. Java: 597)
At org. Apache. Catalina. startup. Bootstrap. Start (Bootstrap. Java: 289)
At org. Apache. Catalina. startup. Bootstrap. Main (Bootstrap. Java: 414)

A bit of Baidu in Google, there is no effective solution. According to the error message, the org. Apache. struts2.dispatcher. Ng. Filter. strutsprepareandexecutefilter class cannot be found. However, I did find this class manually:


To ensure that the class name is not spelled correctly, right-click the strutsprepareandexecutefilter. class file, select "Copy qualified name" (copy the exact name), and paste it to the Web. save and re-run the XML file. The same error occurs, proving that the class name is not spelled correctly.

Finally, I abandoned user libraries and manually copied the related jar of struts2 to the/webcontent/WEB-INF/lib directory:


Run the program again!

That is to say, Tomcat loads resources from the WEB-INF/directory by default, eclipse in the release of the program, the related resources of user libraries are not copied to the WEB-INF/directory (eclipse will put all the non *. java file to the WEB-INF/classes directory), so Tomcat says it cannot find the required class.


Note:

Tool version:

Tomcat: 6.0.32

Eclipse Java EE: 3.6.2

Struts2: 2.2.3

Tool: QQ

Image editing: mspaint

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.