Tomcat6 StackOverflowError when using FORWARD in filter-mapping dispatcher

400 views
Skip to first unread message

tobias...@googlemail.com

unread,
Mar 11, 2010, 8:50:59 AM3/11/10
to UrlRewrite
Hi,

I stumbled over urlrewrite when experimenting with a sample
application called mvc-basic (https://src.springframework.org/svn/
spring-samples/mvc-basic/). Here are the rules:

<urlrewrite default-match-type="wildcard">
<rule>
<from>/images/**</from>
<to>/images/$1</to>
</rule>
<rule>
<from>/scripts/**</from>
<to>/scripts/$1</to>
</rule>
<rule>
<from>/styles/**</from>
<to>/styles/$1</to>
</rule>
<rule>
<from>/**</from>
<to>/app/$1</to>
</rule>
<outbound-rule>
<from>/app/**</from>
<to>/$1</to>
</outbound-rule>
</urlrewrite>

Quite straigtforward. But when changing the configuration to:

...
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
...

in my web.xml I get a StackOverFlow error in my tomcat6 server. The
reason why I need this is that I want to use sitemesh for web page
decoration and urlrewite forwards the pages (at least that is what I
understood). The error message:

javax.servlet.ServletException: Filter execution threw an exception

org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:
195)

org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:
159)
org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:
141)

org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:
90)

org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:
417)

org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:
195)

org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:
159)
org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:
141)

org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:
90)

org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:
417)

org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:
195)
....

Looks like a loop to me? If I leave the FORWARD out the pages aren't
decorated. Any advice? Thank you

Tobias

Avlesh Singh

unread,
Mar 11, 2010, 11:30:00 PM3/11/10
to urlre...@googlegroups.com
How about putting Sitemesh filter before UrlRewriteFilter?

Cheers
Avlesh


--
You received this message because you are subscribed to the Google Groups "UrlRewrite" group.
To post to this group, send email to urlre...@googlegroups.com.
To unsubscribe from this group, send email to urlrewrite+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/urlrewrite?hl=en.


Wim De Smet

unread,
Mar 12, 2010, 3:32:28 AM3/12/10
to urlre...@googlegroups.com
Hi,

It's still early and I'm a bit fuzzy but it looks to me like the above
will work like:
1) request (REQUEST) hits
2) uwf does a FORWARD (say on /images/)
3) uwf is listening to FORWARD events, so it picks up on the request.
4) go to 2

i.e. causing your stack overflow.

regards,
Wim

Tobias Matzat

unread,
Mar 12, 2010, 4:04:33 AM3/12/10
to urlre...@googlegroups.com
Ok, thank you, sounds reasonable to me. But if I just leave the default REQUEST the decoration does not take place?
So I found some forum entry telling me I should add FORWARD too. This leads to the error. And changing the order of
the mappings helps not.


--

Wim De Smet

unread,
Mar 12, 2010, 4:25:10 AM3/12/10
to urlre...@googlegroups.com
What do you mean with "the decoration doesn't take place" though? That
could be any number of things. If you make sure that your other
filters are listening on forwards it should mostly work, as long as
nothing earlier in the chain does forwards, in which case you'd have
to listen to forwards and edit your rules to be less ambiguous, or
maybe make them conditional on something you set on the request.

regards,
Wim

Reply all
Reply to author
Forward
0 new messages