javaeclipsetomcatconfigurationstruts2

Struts2 <filter> and <filter-mapping> causing error


I have a web application using Eclipse, Struts2, and running on a Tomcat 7 Server.

I've been going off of the http://javabrains.koushik.org tutorials.

I have all the basic Struts pieces in place, but for some reason when I introduce this snippet of code into the web.xml.

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

It throws the book at me.

SEVERE: Dispatcher initialization failed
Unable to load configuration. - bean -
Caused by: Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory - bean -     
Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with the name struts has already  been loaded by bean - 
SEVERE: Exception starting filter struts2    
Unable to load configuration. - bean -     
Caused by: Unable to load configuration. - bean -     
Caused by: Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory - bean -    
Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with the name struts has already been loaded by bean - jar:file:/C:/Program%20Files%20(x86)/Apache%20Software%20Foundation/Tomcat%207.0/lib/struts2-core-2.3.16.jar!/struts-default.xml:40:72
- bean -

I know this isn't the complete text dump but I don't know how useful the rest of it would be. I need to understand why it's doing this so I can get it working.


Solution

  • Never mind. It turns out all I needed to do is to forget the build path and only put the jars into the WEB-INF/lib folder. Works like a charm :D