Google Groups Home
Help | Sign in
UrlRewrite not working for Grails?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
J  
View profile
 More options Jul 16, 8:54 am
From: J <lowb...@gmail.com>
Date: Wed, 16 Jul 2008 05:54:12 -0700 (PDT)
Local: Wed, Jul 16 2008 8:54 am
Subject: UrlRewrite not working for Grails?
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.)

The outbound rule does work without problems.

Any idea's what's going wrong?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lucas F. A. Teixeira  
View profile
 More options Jul 16, 8:55 am
From: "Lucas F. A. Teixeira" <lucas...@gmail.com>
Date: Wed, 16 Jul 2008 09:55:45 -0300
Local: Wed, Jul 16 2008 8:55 am
Subject: Re: UrlRewrite not working for Grails?

The Grails default mechanism for urlrewrite doest not fit to you?
[]s,

Lucas

--
Lucas F. A. Teixeira .·.
lucas...@gmail.com

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
J  
View profile
 More options Jul 16, 9:26 am
From: J <lowb...@gmail.com>
Date: Wed, 16 Jul 2008 06:26:17 -0700 (PDT)
Local: Wed, Jul 16 2008 9:26 am
Subject: Re: UrlRewrite not working for 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:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
J  
View profile
 More options Jul 16, 11:10 am
From: J <lowb...@gmail.com>
Date: Wed, 16 Jul 2008 08:10:23 -0700 (PDT)
Local: Wed, Jul 16 2008 11:10 am
Subject: Re: UrlRewrite not working for Grails?
Here the complete debug log.

====== BOOT STRAP ====================
[1390] mapping.DefaultUrlMappingsHolder Reverse mapping:
[DefaultUrlMappingsHolder.UrlMappingKey@1087359 controller = [null],
action = [null], params = set[[empty]]] ->
org.codehaus.groovy.grails.web.mapping.ResponseCodeUrlMapping@1ccf342
[1390] mapping.DefaultUrlMappingsHolder Reverse mapping:
[DefaultUrlMappingsHolder.UrlMappingKey@7691c0 controller = [null],
action = [null], params = set['controller']] -> /(*)/(*)?/(*)?
[1390] mapping.DefaultUrlMappingsHolder Reverse mapping:
[DefaultUrlMappingsHolder.UrlMappingKey@5b02a6 controller = [null],
action = [null], params = set['action', 'controller']] -> /(*)/(*)?/
(*)?
[1392] mapping.DefaultUrlMappingsHolder Reverse mapping:
[DefaultUrlMappingsHolder.UrlMappingKey@10aefdb controller = [null],
action = [null], params = set['id', 'action', 'controller']] -> /(*)/
(*)?/(*)?
[2855] mapping.DefaultUrlMappingsHolder Reverse mapping:
[DefaultUrlMappingsHolder.UrlMappingKey@154145 controller = [null],
action = [null], params = set[[empty]]] ->
org.codehaus.groovy.grails.web.mapping.ResponseCodeUrlMapping@17035c6
[2855] mapping.DefaultUrlMappingsHolder Reverse mapping:
[DefaultUrlMappingsHolder.UrlMappingKey@1da997a controller = [null],
action = [null], params = set['controller']] -> /(*)/(*)?/(*)?
[2855] mapping.DefaultUrlMappingsHolder Reverse mapping:
[DefaultUrlMappingsHolder.UrlMappingKey@921a90 controller = [null],
action = [null], params = set['action', 'controller']] -> /(*)/(*)?/
(*)?
[2856] mapping.DefaultUrlMappingsHolder Reverse mapping:
[DefaultUrlMappingsHolder.UrlMappingKey@de648 controller = [null],
action = [null], params = set['id', 'action', 'controller']] -> /(*)/
(*)?/(*)?
2008-07-16 17:00:18.624:/webapp:INFO:
org.tuckey.web.filters.urlrewrite.utils.Log DEBUG: logLevel set to
DEBUG
2008-07-16 17:00:18.624:/webapp:INFO:
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter DEBUG: confPath set
to /WEB-INF/urlrewrite.xml
2008-07-16 17:00:18.638:/webapp:INFO:
org.tuckey.web.filters.urlrewrite.Conf DEBUG: XML builder factory is:
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
2008-07-16 17:00:18.641:/webapp:INFO:
org.tuckey.web.filters.urlrewrite.Conf DEBUG: XML Parser:
org.apache.xerces.jaxp.DocumentBuilderImpl
2008-07-16 17:00:18.641:/webapp:INFO:
org.tuckey.web.filters.urlrewrite.Conf DEBUG: about to parse conf
2008-07-16 17:00:18.642:/webapp:INFO:
org.tuckey.web.filters.urlrewrite.ConfHandler DEBUG: Resolving to DTD /
org/tuckey/web/filters/urlrewrite/dtds/urlrewrite3.1.dtd
2008-07-16 17:00:18.658:/webapp:INFO:
org.tuckey.web.filters.urlrewrite.Conf DEBUG: now initialising conf
2008-07-16 17:00:18.664:/webapp:INFO:
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: loaded rule Rule 0 (/
mytest, /products/index 1)
2008-07-16 17:00:18.664:/webapp:INFO:
org.tuckey.web.filters.urlrewrite.NormalRule DEBUG: loaded rule Rule 0
(/mytest, /products/index 1)
2008-07-16 17:00:18.664:/webapp:INFO:
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter DEBUG: inited with
1 rules
2008-07-16 17:00:18.664:/webapp:INFO:
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter DEBUG: conf is ok
2008-07-16 17:00:18.666:/webapp:INFO:
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter INFO: loaded (conf
ok)
2008-07-16 17:00:18.735:/webapp:INFO:  Initializing Spring
FrameworkServlet 'grails'
2008-07-16 17:00:18.904::INFO:  Started
SelectChannelConnec...@0.0.0.0:8080
Server running. Browse to http://localhost:8080/webapp

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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
J  
View profile
 More options Jul 16, 1:32 pm
From: J <lowb...@gmail.com>
Date: Wed, 16 Jul 2008 10:32:13 -0700 (PDT)
Local: Wed, Jul 16 2008 1:32 pm
Subject: Re: UrlRewrite not working for Grails?
http://www.nabble.com/UrlRewriteFilter-not-working-for-Grails--td1848...
The problem is Grails. It doesn't support forward dispatchers.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google