Discussion:
Struts dispatcher apparently not started
Fabian Richter
2013-06-26 10:37:23 UTC
Permalink
Hello all,

I am faily new with struts, and to get a grip on the mechanics I
volunteered to migrate one of our applications from Webwork to struts2
latest.

So far I made progress, the application is not only running but also
rendered some UI in the browser.

But I have exceptions like

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. - [unknown location]
at org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:60)
at
org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:44)
at
org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:48)

On every action I do on the website.

I am always calling actions (as far as I know) so no .jsp pages directly.

My web.xml looks like:

-------%< SNIP ------------

<filter>
<filter-name>appFilter</filter-name>
<filter-class>own.ApplicationFilter</filter-class>
</filter>

<filter>
<filter-name>struts-prepare</filter-name>

<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter</filter-class>
</filter>
<filter>
<filter-name>struts-execute</filter-name>

<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter</filter-class>
</filter>

<filter>
<filter-name>sitemesh</filter-name>

<filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>appFilter</filter-name>
<url-pattern>*.html</url-pattern>
</filter-mapping>

<filter-mapping>
<filter-name>struts-prepare</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>

<filter-mapping>
<filter-name>struts-execute</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<listener>
<listener-class>own.StartupListener</listener-class>
</listener>

<listener>

<listener-class>org.apache.struts2.dispatcher.ng.listener.StrutsListener</listener-class>
</listener>

<listener>

<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>


<servlet>
<servlet-name>sitemesh-freemarker</servlet-name>

<servlet-class>org.apache.struts2.sitemesh.FreemarkerDecoratorServlet</servlet-class>
<init-param>
<param-name>default_encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>sitemesh-freemarker</servlet-name>
<url-pattern>*.ftl</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>JspSupportServlet</servlet-name>

<servlet-class>org.apache.struts2.views.JspSupportServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

-------%< SNIP ------------

The rest of the file is simple configuration. I thought by calling the
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter right after
my AppFilter (which handles cert based authentification) I would already
be calling the Struts Dispatcher, but apparently thats where I'm wrong?

Thank you for your help to a newbie!

Best
Fabian
vEnkaTa mohAna rAo SriperumbUdUru
2013-06-27 03:14:48 UTC
Permalink
http://struts.apache.org/release/2.3.x/struts2-core/apidocs/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareAndExecuteFilter.html
try to point to this filter. Usually get the above message when you are
using struts2 tags in jsp trying to display and not passing through the
StrutsPrepareAndExecuteFilter filter.
Post by Fabian Richter
Hello all,
I am faily new with struts, and to get a grip on the mechanics I
volunteered to migrate one of our applications from Webwork to struts2
latest.
So far I made progress, the application is not only running but also
rendered some UI in the browser.
But I have exceptions like
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. - [unknown location]
at org.apache.struts2.views.jsp.**TagUtils.getStack(TagUtils.**
java:60)
at org.apache.struts2.views.jsp.**StrutsBodyTagSupport.getStack(**
StrutsBodyTagSupport.java:44)
at org.apache.struts2.views.jsp.**ComponentTagSupport.**
doStartTag(**ComponentTagSupport.java:48)
On every action I do on the website.
I am always calling actions (as far as I know) so no .jsp pages directly.
-------%< SNIP ------------
<filter>
<filter-name>appFilter</**filter-name>
<filter-class>own.**ApplicationFilter</filter-**class>
</filter>
<filter>
<filter-name>struts-prepare</**filter-name>
<filter-class>org.apache.**struts2.dispatcher.ng.filter.**
StrutsPrepareFilter</filter-**class>
</filter>
<filter>
<filter-name>struts-execute</**filter-name>
<filter-class>org.apache.**struts2.dispatcher.ng.filter.**
StrutsExecuteFilter</filter-**class>
</filter>
<filter>
<filter-name>sitemesh</filter-**name>
<filter-class>com.**opensymphony.sitemesh.webapp.**
SiteMeshFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>appFilter</**filter-name>
<url-pattern>*.html</url-**pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts-prepare</**filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>sitemesh</filter-**name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</**dispatcher>
<dispatcher>FORWARD</**dispatcher>
<dispatcher>INCLUDE</**dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>struts-execute</**filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>own.**StartupListener</listener-**class>
</listener>
<listener>
<listener-class>org.apache.**struts2.dispatcher.ng.**
listener.StrutsListener</**listener-class>
</listener>
<listener>
<listener-class>org.**springframework.web.util.**
Log4jConfigListener</listener-**class>
</listener>
<servlet>
<servlet-name>sitemesh-**freemarker</servlet-name>
<servlet-class>org.apache.**struts2.sitemesh.**
FreemarkerDecoratorServlet</**servlet-class>
<init-param>
<param-name>default_encoding</**param-name>
<param-value>UTF-8</param-**value>
</init-param>
<load-on-startup>1</load-on-**startup>
</servlet>
<servlet-mapping>
<servlet-name>sitemesh-**freemarker</servlet-name>
<url-pattern>*.ftl</url-**pattern>
</servlet-mapping>
<servlet>
<servlet-name>**JspSupportServlet</servlet-**name>
<servlet-class>org.apache.**struts2.views.**JspSupportServlet</servlet-**
class>
<load-on-startup>1</load-on-**startup>
</servlet>
-------%< SNIP ------------
The rest of the file is simple configuration. I thought by calling the
org.apache.struts2.dispatcher.**ng.filter.StrutsPrepareFilter right after
my AppFilter (which handles cert based authentification) I would already be
calling the Struts Dispatcher, but apparently thats where I'm wrong?
Thank you for your help to a newbie!
Best
Fabian
Fabian Richter
2013-06-27 06:15:57 UTC
Permalink
I am using

http://struts.apache.org/release/2.3.x/struts2-core/apidocs/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareFilter.html

then sitemesh, my own filter then

http://struts.apache.org/release/2.3.x/struts2-core/apidocs/org/apache/struts2/dispatcher/ng/filter/StrutsExecuteFilter.html

Isnt that the same as just using the one you proposed?

Also: Where do I put my OwnApplicationFilter? Before the StrutsPrepare,
or afterwards?

Best
Fabian
Post by vEnkaTa mohAna rAo SriperumbUdUru
http://struts.apache.org/release/2.3.x/struts2-core/apidocs/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareAndExecuteFilter.html
try to point to this filter. Usually get the above message when you are
using struts2 tags in jsp trying to display and not passing through the
StrutsPrepareAndExecuteFilter filter.
Post by Fabian Richter
Hello all,
I am faily new with struts, and to get a grip on the mechanics I
volunteered to migrate one of our applications from Webwork to struts2
latest.
So far I made progress, the application is not only running but also
rendered some UI in the browser.
But I have exceptions like
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. - [unknown location]
at org.apache.struts2.views.jsp.**TagUtils.getStack(TagUtils.**
java:60)
at org.apache.struts2.views.jsp.**StrutsBodyTagSupport.getStack(**
StrutsBodyTagSupport.java:44)
at org.apache.struts2.views.jsp.**ComponentTagSupport.**
doStartTag(**ComponentTagSupport.java:48)
On every action I do on the website.
I am always calling actions (as far as I know) so no .jsp pages directly.
-------%< SNIP ------------
<filter>
<filter-name>appFilter</**filter-name>
<filter-class>own.**ApplicationFilter</filter-**class>
</filter>
<filter>
<filter-name>struts-prepare</**filter-name>
<filter-class>org.apache.**struts2.dispatcher.ng.filter.**
StrutsPrepareFilter</filter-**class>
</filter>
<filter>
<filter-name>struts-execute</**filter-name>
<filter-class>org.apache.**struts2.dispatcher.ng.filter.**
StrutsExecuteFilter</filter-**class>
</filter>
<filter>
<filter-name>sitemesh</filter-**name>
<filter-class>com.**opensymphony.sitemesh.webapp.**
SiteMeshFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>appFilter</**filter-name>
<url-pattern>*.html</url-**pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts-prepare</**filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>sitemesh</filter-**name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</**dispatcher>
<dispatcher>FORWARD</**dispatcher>
<dispatcher>INCLUDE</**dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>struts-execute</**filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>own.**StartupListener</listener-**class>
</listener>
<listener>
<listener-class>org.apache.**struts2.dispatcher.ng.**
listener.StrutsListener</**listener-class>
</listener>
<listener>
<listener-class>org.**springframework.web.util.**
Log4jConfigListener</listener-**class>
</listener>
<servlet>
<servlet-name>sitemesh-**freemarker</servlet-name>
<servlet-class>org.apache.**struts2.sitemesh.**
FreemarkerDecoratorServlet</**servlet-class>
<init-param>
<param-name>default_encoding</**param-name>
<param-value>UTF-8</param-**value>
</init-param>
<load-on-startup>1</load-on-**startup>
</servlet>
<servlet-mapping>
<servlet-name>sitemesh-**freemarker</servlet-name>
<url-pattern>*.ftl</url-**pattern>
</servlet-mapping>
<servlet>
<servlet-name>**JspSupportServlet</servlet-**name>
<servlet-class>org.apache.**struts2.views.**JspSupportServlet</servlet-**
class>
<load-on-startup>1</load-on-**startup>
</servlet>
-------%< SNIP ------------
The rest of the file is simple configuration. I thought by calling the
org.apache.struts2.dispatcher.**ng.filter.StrutsPrepareFilter right after
my AppFilter (which handles cert based authentification) I would already be
calling the Struts Dispatcher, but apparently thats where I'm wrong?
Thank you for your help to a newbie!
Best
Fabian
--
media transfer AG

Fabian Richter, M.Sc.
Softwareentwickler

Mail: ***@mtg.de
Telefon: +49 6151 8193-24
Telefax: +49 6151 8193-41
Web: http://www.mtg.de

Firmensitz: Dolivostraße 11, 64293 Darmstadt
Registergericht: Amtsgericht Darmstadt, HRB 8901
Vorstand: Jürgen Ruf (Vors.), Tamer Kemeröz
Aufsichtsratsvorsitzender: Dr. Thomas Milde
Lukasz Lenart
2013-06-27 06:23:12 UTC
Permalink
Post by Fabian Richter
I am using
http://struts.apache.org/release/2.3.x/struts2-core/apidocs/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareFilter.html
then sitemesh, my own filter then
http://struts.apache.org/release/2.3.x/struts2-core/apidocs/org/apache/struts2/dispatcher/ng/filter/StrutsExecuteFilter.html
Isnt that the same as just using the one you proposed?
You are using it right, when using SItemesh you must the two - Prepare
and Execute
Post by Fabian Richter
Also: Where do I put my OwnApplicationFilter? Before the StrutsPrepare, or
afterwards?
The questions is what its doing? If something that doesn't depend on
Struts, before.


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
Fabian Richter
2013-06-27 06:33:21 UTC
Permalink
Post by Lukasz Lenart
The questions is what its doing? If something that doesn't depend on
Struts, before.
It handles the certificate based authentication and configures the user
session before displaying any web content.

So before it is?
Lukasz Lenart
2013-06-27 06:37:59 UTC
Permalink
Post by Fabian Richter
Post by Lukasz Lenart
The questions is what its doing? If something that doesn't depend on
Struts, before.
It handles the certificate based authentication and configures the user
session before displaying any web content.
So before it is?
In my opinion, yes.


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
Lukasz Lenart
2013-06-27 05:38:49 UTC
Permalink
What URL do you enter to get the exception?


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
Post by Fabian Richter
Hello all,
I am faily new with struts, and to get a grip on the mechanics I volunteered
to migrate one of our applications from Webwork to struts2 latest.
So far I made progress, the application is not only running but also
rendered some UI in the browser.
But I have exceptions like
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. - [unknown location]
at org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:60)
at
org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:44)
at
org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:48)
On every action I do on the website.
I am always calling actions (as far as I know) so no .jsp pages directly.
-------%< SNIP ------------
<filter>
<filter-name>appFilter</filter-name>
<filter-class>own.ApplicationFilter</filter-class>
</filter>
<filter>
<filter-name>struts-prepare</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter</filter-class>
</filter>
<filter>
<filter-name>struts-execute</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter</filter-class>
</filter>
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>appFilter</filter-name>
<url-pattern>*.html</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts-prepare</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>struts-execute</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>own.StartupListener</listener-class>
</listener>
<listener>
<listener-class>org.apache.struts2.dispatcher.ng.listener.StrutsListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<servlet>
<servlet-name>sitemesh-freemarker</servlet-name>
<servlet-class>org.apache.struts2.sitemesh.FreemarkerDecoratorServlet</servlet-class>
<init-param>
<param-name>default_encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>sitemesh-freemarker</servlet-name>
<url-pattern>*.ftl</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>JspSupportServlet</servlet-name>
<servlet-class>org.apache.struts2.views.JspSupportServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
-------%< SNIP ------------
The rest of the file is simple configuration. I thought by calling the
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter right after my
AppFilter (which handles cert based authentification) I would already be
calling the Struts Dispatcher, but apparently thats where I'm wrong?
Thank you for your help to a newbie!
Best
Fabian
Fabian Richter
2013-06-27 06:17:33 UTC
Permalink
Hi Lukas,

I am getting that on every call: for example the root path:

https://localhost/app/

which forwards to

https://localhost/app/index.html

Best
Fabian
Post by Lukasz Lenart
What URL do you enter to get the exception?
Regards
Lukasz Lenart
2013-06-27 06:21:25 UTC
Permalink
Post by Fabian Richter
https://localhost/app/
Do you have IndexAction or so defined?
Post by Fabian Richter
which forwards to
https://localhost/app/index.html
Could you share your struts.xml?


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
Fabian Richter
2013-06-27 06:28:04 UTC
Permalink
Post by Lukasz Lenart
Do you have IndexAction or so defined?
Yes, and many other actions. Wann see the code? Pretty much standard :/
Post by Lukasz Lenart
Could you share your struts.xml?
Uhm, its a 500 line file thats including a few others. I might have to
anonymize and put it on pastebin or something.

What exactly are you looking for? Maybe I can extract parts into an email.

Best
Fabian
Lukasz Lenart
2013-06-27 06:31:07 UTC
Permalink
Post by Fabian Richter
Uhm, its a 500 line file thats including a few others. I might have to
anonymize and put it on pastebin or something.
What exactly are you looking for? Maybe I can extract parts into an email.
How did you define index action?


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
Fabian Richter
2013-06-27 06:39:16 UTC
Permalink
Post by Lukasz Lenart
How did you define index action?
<bean id="indexAction" class="my.webapp.action.IndexAction"
singleton="false">
<property name="roleIdentifiers">
<list>
<value>role.id</value>
</list>
</property>
</bean>

In action-servlet.xml which is included from web.xml:

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:wsClientApplicationContext.xml,
classpath:webappApplicationContext.xml,
classpath:action-servlet.xml, classpath:fcore-action-servlet.xml
</param-value>
</context-param>
Lukasz Lenart
2013-06-27 06:42:07 UTC
Permalink
Post by Fabian Richter
Post by Lukasz Lenart
How did you define index action?
<bean id="indexAction" class="my.webapp.action.IndexAction"
singleton="false">
<property name="roleIdentifiers">
<list>
<value>role.id</value>
</list>
</property>
</bean>
This how you build the action ;-) Please show me your struts.xml ;-)


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
Fabian Richter
2013-06-27 06:44:14 UTC
Permalink
Post by Lukasz Lenart
This how you build the action ;-) Please show me your struts.xml ;-)
Sorry, after I sent it, I was wondering if that was what you meant :)


<action name="index" class="indexAction" method="index">
<result name="success">/WEB-INF/pages/index.jsp</result>
<result
name="success-tcop.tcop.role.id">/WEB-INF/pages/index.jsp</result>
</action>
Lukasz Lenart
2013-06-27 06:46:50 UTC
Permalink
Post by Fabian Richter
Sorry, after I sent it, I was wondering if that was what you meant :)
<action name="index" class="indexAction" method="index">
<result name="success">/WEB-INF/pages/index.jsp</result>
<result
name="success-tcop.tcop.role.id">/WEB-INF/pages/index.jsp</result>
</action>
Ok, looks good. So why I said it forwards to https://localhost/app/index.html ?


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
Fabian Richter
2013-06-27 06:51:04 UTC
Permalink
Post by Lukasz Lenart
Ok, looks good. So why I said it forwards to https://localhost/app/index.html ?
I meant when I call https://localhost/app/ the url is rewritten by the
app to https://localhost/app/index.html
Lukasz Lenart
2013-06-27 06:59:43 UTC
Permalink
I meant when I call https://localhost/app/ the url is rewritten by the app
to https://localhost/app/index.html
Looks like one of your filters messing things up. Try to comment out this

<filter-mapping>
<filter-name>appFilter</filter-name>
<url-pattern>*.html</url-pattern>
</filter-mapping>


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
Fabian Richter
2013-06-27 07:02:23 UTC
Permalink
Post by Lukasz Lenart
I meant when I call https://localhost/app/ the url is rewritten by the app
to https://localhost/app/index.html
Looks like one of your filters messing things up. Try to comment out this
<filter-mapping>
<filter-name>appFilter</filter-name>
<url-pattern>*.html</url-pattern>
</filter-mapping>
This is the Authentication filter. If I comment that one out, I get
authorization not initialized exceptions in my application.

Best
Fabian
Lukasz Lenart
2013-06-27 07:05:39 UTC
Permalink
Post by Fabian Richter
Post by Lukasz Lenart
I meant when I call https://localhost/app/ the url is rewritten by the app
to https://localhost/app/index.html
Looks like one of your filters messing things up. Try to comment out this
<filter-mapping>
<filter-name>appFilter</filter-name>
<url-pattern>*.html</url-pattern>
</filter-mapping>
This is the Authentication filter. If I comment that one out, I get
authorization not initialized exceptions in my application.
Hmm... so why do you map it to *.html? And not to /* or *.action?


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
Fabian Richter
2013-06-27 07:12:08 UTC
Permalink
Post by Lukasz Lenart
Hmm... so why do you map it to *.html? And not to /* or *.action?
It was like that in the original web.xml when the application ran with
Webwork. I also tried /* without changes.

But I had some progress in my "Dispatcher not started" problem:
Apparently an old .css file was still linked in the main decorator jsp.
The 404 (for whatever reason) created an exception that killed the
dispatcher? Or maybe it just said so...

Now I dont have that error on every page anymore, but my struts tags
still dont render correctly :(

I will have a deeper look into that and get back to the list if I need
help understanding the tags (the wiki didnt help so far, if and elseif
arent working at all here)

Thank you Lukasz for your help! At least now I know most of the app is
configured correctly wrt struts2 :)

Best
Fabian

Continue reading on narkive:
Loading...