This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Struts and the fly likes The Struts dispatcher cannot be found error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "The Struts dispatcher cannot be found error" Watch "The Struts dispatcher cannot be found error" New topic
Author

The Struts dispatcher cannot be found error

Harshani Wickramarathna
Greenhorn

Joined: Nov 15, 2007
Posts: 28
Hi.

I just try to migrate struts.. and get this
Error.......
The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag.

how can i overcome this?

thanks
Lela Latsoshvili
Greenhorn

Joined: Feb 07, 2008
Posts: 4
Hi,
I think I've got the same problem.
I have just started working with struts2, so I am not very good at it.
Still i think you need to write about that dipatcher in the web.xml file if do not have it already written.



So, it'll find the filter dispatcher.

As far as my problem is concerned, when I start tomcat and view my site on localhost, it's working properly until I need an action class. And at that point I get the error "The Struts dispatcher cannot be found"
Then I found out that eclipse had deleted my web.xml (or I do not know where it has vanished)..
I rewrote it again (web.xml) and put in the WEB-INF folder again, but now I cannot start my site.. not even the index.html page.

"requested resource is not available"..

Any ideas?


I haven't failed. I have just found 10 000 ways that won't work <br /> <br /><br />p.s. Samurai
Lela Latsoshvili
Greenhorn

Joined: Feb 07, 2008
Posts: 4
Found
my mistake..
I had mistake in struts.xml
Harshani Wickramarathna
Greenhorn

Joined: Nov 15, 2007
Posts: 28
Hi Samurai,

Thanks 4 the reply. But I have put that code you have given in the web.xml
but it didn't work..!!

Anyway thanks again

Do you have any idea about migtating struts1 application to struts2?
If so please let me know..

Harshani
Lela Latsoshvili
Greenhorn

Joined: Feb 07, 2008
Posts: 4
Hi Harshani,

These articles seem quite interesting to me..
Migrating Struts Apps to Struts 2

and here is a good tutorial for Struts2 from roseindia.net
Struts 2 tutorial
Harshani Wickramarathna
Greenhorn

Joined: Nov 15, 2007
Posts: 28
Thank you very much Samurai...

Lela Latsoshvili
Greenhorn

Joined: Feb 07, 2008
Posts: 4
Good luck

p.s. it's me again
Jitmer Jijo
Greenhorn

Joined: Oct 17, 2010
Posts: 6
Change the filter as follows and the <url-pattern>/*</url-pattern> should be /* and it should work.

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

Pooja Shah
Greenhorn

Joined: Jan 05, 2009
Posts: 13
Just started with struts, and facing the same problem as Lela.
Any suggestions ?
Kr. Gaurav
Greenhorn

Joined: Jul 27, 2011
Posts: 1
FilterDispatcher not found error details ;

This error is happening because of container is unable to find the relevant class StrutsPrepareAndExecuteFilter.class & FilterDispatcher.class respectively
after reading the Deployment Descriptor.

Make the above class available to the container you must copy the strut2-core.jar into the lib directory under WEB_INF Folder. You can easily find the above
two classes into these packages org.apache.struts2.dispatcher.ng.filter & org.apache.struts2.dispatcher respectively, that is available into the JAR file.
[ Unjar the strut2-core.jar file to see these package ]

**************************************************************************************************************************************

And there are no difference at all in these two element both do same thing. Both elements are just a convention to map our request towards the Strut Framework.
Both abs works fine with me. But yes d only one difference is there ;

// Deprecated since Strut 2.1.3 to split-up the dispatcher phases. But still working
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>

So, we must follow the new convention written below thts it
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>

Tested with Apache-Tomcat on Eclipse IDE

Hope everything is clear by now !!!
maya mohan sagar
Greenhorn

Joined: May 08, 2011
Posts: 1

Kr. Gaurav wrote:FilterDispatcher not found error details ;

This error is happening because of container is unable to find the relevant class StrutsPrepareAndExecuteFilter.class & FilterDispatcher.class respectively
after reading the Deployment Descriptor.

Make the above class available to the container you must copy the strut2-core.jar into the lib directory under WEB_INF Folder. You can easily find the above
two classes into these packages org.apache.struts2.dispatcher.ng.filter & org.apache.struts2.dispatcher respectively, that is available into the JAR file.
[ Unjar the strut2-core.jar file to see these package ]

**************************************************************************************************************************************

And there are no difference at all in these two element both do same thing. Both elements are just a convention to map our request towards the Strut Framework.
Both abs works fine with me. But yes d only one difference is there ;

// Deprecated since Strut 2.1.3 to split-up the dispatcher phases. But still working
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>

So, we must follow the new convention written below thts it
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>

Tested with Apache-Tomcat on Eclipse IDE

Hope everything is clear by now !!!


----------------------------------------
Thanks Gaurav.. great explanation !!


There are two ways of spreading light: to be the candle or the mirror that reflects it.
Souvvik Basu
Ranch Hand

Joined: Apr 05, 2010
Posts: 96
hi Gaurav,
I have put the struts2-core-2.0.11 jar in the lib directory under WEB-INF directory. I have also declared the dispatcher in my web.xml, which I have put along with the WEB-INF directory, as it should be.



I still get that error.
Can you please suggest why this is happening?

I've been stuck up at this place for several days now. Please help!!
Souvvik Basu
Ranch Hand

Joined: Apr 05, 2010
Posts: 96
Found my error.....

Was placing the web.xml file outside the WEB-INF directory
Benjamin Pope
Greenhorn

Joined: Sep 05, 2011
Posts: 10
I am getting this error although my web app was working fine when I went to bed. Shut down my laptop and when I woke up I started getting a 404 not found. I had to remove the web app from the server in eclipse and then I got this error. I have the struts-core jar file in web-inf and my web.xml file looks like this:



To me, this is inconsistent behavior. I'm not sure what the problem could be but it is disheartening to say the least.

Edit: I changed the filter-class to the FilterDispatcher and now the page loads fine. I'm still wondering why if someone could shed some light, I'd really appreciate it.
Mahendr Shinde
Ranch Hand

Joined: Sep 03, 2011
Posts: 38

Hi Benjamin,
in your code, you have used "org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter" which is a new Dispatcher available in struts2. It may have some dependencies (like additional .jar files other than struts-core). If you are using newer features of Struts2 they requires few extra jars and yes they required newer versions. so while creating struts applications, you should always have all required libraries.

There is still lot to learn!
Benjamin Pope
Greenhorn

Joined: Sep 05, 2011
Posts: 10
Thanks. Any idea as to why I received the 404 not found error when it was just working the night before and all I did was shutdown my laptop? I am noticing that it also is happening as I make changes to the struts.xml config file. Once I make a change, the whole site becomes unavailable.

Edit: I think I solved the problem. It seems to be an eclipse problem, not a struts problem. I was cleaning the tomcat working directory and also trying to clean the project by right clicking the server and clicking clean, but this was not working. When I used the Projects menus at the top of the ide, the problem was corrected.
sathyaraj ananthapndian
Greenhorn

Joined: Jul 17, 2012
Posts: 1
Hi Lela Latsoshvili

what is the error in struts.xml file.

i too getting the same error. which you told

please tell me...

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: The Struts dispatcher cannot be found error