I'm trying to get the Grails webframework working with Tuckey's Url
Rewrite Filter, but somehow Grails doesn't seem to accept a simple
rule.
Versions:
-UrlRewriteFilter 2.6 and 3.1.0
-Grails 1.0.3
-Webserver: tested both Jetty 6.1.4 and Tomcat 6.0.14
Settings:
-I configured UrlReWriteFilter as first filter in web.xml.
-urlrewrite.xml has the rule: <rule><from>/mytest</from><to>/products/
index</to></rule>, and a similar outbound rule.
Results:
Browsing to http://localhost:8080/webapp/products/index will directly
show the Grails page bypassing urlrewrite because no inbound rules are
configured for that URL. When browsing to http://localhost:8080/webapp/mytest,
the rule is found by UrlRewrite, but somehow a 404 error pops up. The
404 error shows: "The requested resource (/webapp/products/index) is
not available". Which is strange because that url does work when
directly browsing to it.
I also testing it further with ROOT (empty) context, so the context
should not be the problem. (Also I didn't have any problem when using
simple servlets instead of Grails.)
On Wed, Jul 16, 2008 at 9:54 AM, J <lowb...@gmail.com> wrote:
> I'm trying to get the Grails webframework working with Tuckey's Url
> Rewrite Filter, but somehow Grails doesn't seem to accept a simple
> rule.
> Versions:
> -UrlRewriteFilter 2.6 and 3.1.0
> -Grails 1.0.3
> -Webserver: tested both Jetty 6.1.4 and Tomcat 6.0.14
> Settings:
> -I configured UrlReWriteFilter as first filter in web.xml.
> -urlrewrite.xml has the rule: <rule><from>/mytest</from><to>/products/
> index</to></rule>, and a similar outbound rule.
> Results:
> Browsing to http://localhost:8080/webapp/products/index will directly
> show the Grails page bypassing urlrewrite because no inbound rules are
> configured for that URL. When browsing to
> http://localhost:8080/webapp/mytest,
> the rule is found by UrlRewrite, but somehow a 404 error pops up. The
> 404 error shows: "The requested resource (/webapp/products/index) is
> not available". Which is strange because that url does work when
> directly browsing to it.
> I also testing it further with ROOT (empty) context, so the context
> should not be the problem. (Also I didn't have any problem when using
> simple servlets instead of Grails.)
I like it that Grails has urlmappings (compared to other
webframeworks), but it is not as advanced/flexible as Tuckeys
UrlRewriteFilter. For example, Grails doesn't support regex in
urlmapping method names, only wildcards and tokens are supported
there. It does support regex in urlmapping constraints, but not in the
method names.
But the case in my first post should work, right? Grails should have
no knowledge that URLs are being rewritten by UrlRewriteFilter.
On 16 jul, 14:55, "Lucas F. A. Teixeira" <lucas...@gmail.com> wrote:
> The Grails default mechanism for urlrewrite doest not fit to you?
> []s,
> Lucas
> On Wed, Jul 16, 2008 at 9:54 AM, J <lowb...@gmail.com> wrote:
> > I'm trying to get the Grails webframework working with Tuckey's Url
> > Rewrite Filter, but somehow Grails doesn't seem to accept a simple
> > rule.
> > Versions:
> > -UrlRewriteFilter 2.6 and 3.1.0
> > -Grails 1.0.3
> > -Webserver: tested both Jetty 6.1.4 and Tomcat 6.0.14
> > Settings:
> > -I configured UrlReWriteFilter as first filter in web.xml.
> > -urlrewrite.xml has the rule: <rule><from>/mytest</from><to>/products/
> > index</to></rule>, and a similar outbound rule.
> > Results:
> > Browsing tohttp://localhost:8080/webapp/products/indexwill directly
> > show the Grails page bypassing urlrewrite because no inbound rules are
> > configured for that URL. When browsing to
> >http://localhost:8080/webapp/mytest,
> > the rule is found by UrlRewrite, but somehow a 404 error pops up. The
> > 404 error shows: "The requested resource (/webapp/products/index) is
> > not available". Which is strange because that url does work when
> > directly browsing to it.
> > I also testing it further with ROOT (empty) context, so the context
> > should not be the problem. (Also I didn't have any problem when using
> > simple servlets instead of Grails.)
> > The outbound rule does work without problems.
> > Any idea's what's going wrong?
> --
> Lucas F. A. Teixeira .·.
> lucas...@gmail.com- Tekst uit oorspronkelijk bericht niet weergeven -
=========== Direct Grails URL request (/webapp/products/index)
=====================
2008-07-16 17:00:31.578:/webapp:INFO:
org.tuckey.web.filters.urlrewrite.utils.ServerNameMatcher DEBUG:
looking for hostname match on current server name localhost
2008-07-16 17:00:31.580:/webapp:INFO:
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter DEBUG: checking for
status path on /webapp/products/index
2008-07-16 17:00:31.580:/webapp:INFO:
org.tuckey.web.filters.urlrewrite.UrlRewriter DEBUG: processing
request for /webapp/products/index
2008-07-16 17:00:31.580:/webapp:INFO:
org.tuckey.web.filters.urlrewrite.UrlRewriter DEBUG: context removed
from url
2008-07-16 17:00:31.584:/webapp:INFO:
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: Rule 0 run called
with /products/index
[16217] mapping.DefaultUrlMappingsHolder Attempting to match URI [/
products/index] with pattern [500]
[16218] mapping.DefaultUrlMappingsHolder Attempting to match URI [/
products/index] with pattern [/(*)/(*)?/(*)?]
[16237] mapping.DefaultUrlMappingsHolder Matched URI [/products/index]
with pattern [/(*)/(*)?/(*)?], adding to posibilities
=========== Rewritten URL request (/webapp/mytest) ==================
2008-07-16 17:00:41.417:/webapp:INFO:
org.tuckey.web.filters.urlrewrite.utils.ServerNameMatcher DEBUG:
looking for hostname match on current server name localhost
2008-07-16 17:00:41.417:/webapp:INFO:
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter DEBUG: checking for
status path on /webapp/mytest
2008-07-16 17:00:41.417:/webapp:INFO:
org.tuckey.web.filters.urlrewrite.UrlRewriter DEBUG: processing
request for /webapp/mytest
2008-07-16 17:00:41.417:/webapp:INFO:
org.tuckey.web.filters.urlrewrite.UrlRewriter DEBUG: context removed
from url
2008-07-16 17:00:41.418:/webapp:INFO:
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: Rule 0 run called
with /mytest
2008-07-16 17:00:41.418:/webapp:INFO:
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: matched "from"
2008-07-16 17:00:41.422:/webapp:INFO:
org.tuckey.web.filters.urlrewrite.RuleExecutionOutput DEBUG: needs to
be forwarded to /products/index
As you can see, a direct Grails URL request works as expected:
Urlrewrite will filter it first and won't find a rule for it, and then
Grails urlmapping will find a rule and shows the page.
In the second request -the rewritten URL request- Urlrewrite will find
a rule and forwards it to /webapp/products/index, BUT Grails
urlmapping doesn't seem to be called now???
And a 404 page will show: "NOT_FOUND RequestURI=/webapp/products/
index".
Any ideas why Grails urlmapping doesn't work when an URL is forwarded
by Urlrewrite? Grails should be unaware of any action performed by
Urlrewrite, right?