Struts2 web.xml file filter for creating a web application

I'm currently trying to create a small web application using the Struts2 framework. (In the eclipse)

I'm currently trying to use a filter in the web.xml file (in the WEB-INF folder) to transfer control to the struts.xml file (in the src folder). (This is what I saw in the textbook).

The code I use for the filter is as follows:

<filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> 

I don’t think Tomcat finds the class in the JAR files for the filter, as I keep getting the following error:

java.lang.NoClassDefFoundError: com / opensymphony / xwork2 / ActionContext at org.apache.struts2.dispatcher.ng.InitOperations.cleanup (InitOperations.java:114) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareterExecuteFrepilterExute (StrutsPrepareAndExecuteFilter.java:60)
... has been going on for quite some time.

I have Jar files downloaded from the Struts web page, and the way I began to set the build path is as follows:

I right-click on the project and go to properties

Moved to the Java Build Path section and created a new library

All Jar files are added to this library and assigned to this path for creating the web application.

Then I added this Jar library to the deployment assembly so that when it was launched it would be deployed to the WEB-INF / lib folder.

As far as I know, this should work, as it works in the tutorial I followed! However, this does not work for me.

When I start my project and move on my computer to where the project is saved, if I look in the WEB-INF / lib folder, there are no Jar files there, could it be where the problem is? Or is this normal?

Thanks for any help, this is much appreciated!

EDIT

Here are the jar files that I use:

 commons-fileupload-1.2.2 commons-io-2.0.1 commons-logging-1.1.1 commons-logging-api-1.1 freemarker-2.3.19 javaassist-3.11.0.GA ognl-3.0.6 struts2-core-2.3.8 xwork-core-2.3.8 commons-lang-2.4 

SOLVED - Solved by completely restarting the project in the new assembly! UPDATE is also a fixed old assembly, deleting all banks and recreating the jar library and reassigning it to the assembly / assembly path Deplyment (this was hundreds of times when trying to debug, though)

Then deleted the old Tomcat server and assigned a new one.

Not quite sure I fixed it, but it all works, for now

+4
source share
1 answer

If you open the Markers view, there should be a dependency on the Warning system class of warning messages . If you expand this group, you should see some warnings similar to:

Entering classpath ??? will not be exported or published . RuntimeClassNotFoundExceptions may occur.

Right-click these warnings and select Quick Fix . This allows you to mark the classpath entry for inclusion in WEB-INF / lib.

+2
source

All Articles