views:

1675

answers:

3

I'm following Scott Davis' tutorials on developing grails apps, but whenever i try to run my app (or indeed his source code) i get "Firefox has detected that the server is redirecting the request for this address in a way that will never complete." Safari gives a similar error message as does Opera.

As i've tested the original authors source code which gives the same error i'm fairly confident it's nothing to do with the code.

Is this a problem with the web server on my machine? I use Mac OS Snow Leopard so i'm assuming it's apache that's generating this error.

Edit: Seems Grails as standard uses Jetty, so probably not Apache that is causing the problem. However also tested the app on Glassfish and i get the same error.

Anyone know what i can do to fix this?

Cheers

+2  A: 

I was getting the same error a little while ago, heres how I fixed:

  1. Try the same page on a different internet setup (it could be your ISP)
  2. Open up Safari, Firefox or whatever your using and empty the cache and delete ALL your cookies
  3. Reboot your computer and try again

It may work now, but if it doesn't:

  1. open up Firefox and type 'about:config' (without the quotes) into the URL bar
  2. You will get some little warning, just press OK
  3. Type 'redirect' into the Filter box
  4. You should see a listing for 'network.http.redirection-limit'
  5. Double click the listing and type a large number (anything above 50 and lower than 200)
  6. Press OK, quit and re-open FireFox

Basically all that does is make FireFox's tolerance for redirect loops higher which should fix your problem - but usually, just borrowing someone else's internet connection fixes it

Hope that all helps =)

Cal S
Cheers,Still not working. I'll have a crack on windows to see if i get the same problem.
Doozer1979
np, feel free to rate up ;)
Cal S
+3  A: 

It depends on the code and Apache configuration you are using. I assume that the web server sends cyclic HTTP redirections, eg. from /root/ to /root (without the slash) and vice versa. This causes a redirection infinite loop.

Check your configuration on conditions that cause a HTTP redirect. For example, Apache automatically adds slashes to directory URLs in standard configuration (like the /root/ example above). I don't know Grails, so I cannot give you a hint on how URLs are processed within the app.

You can also use manual HTTP requests for debugging to see whats going on behind the scenes, using telnet on a terminal:

$ telnet localhost 80
GET / HTTP/1.0

I guess the response will be something like that:

HTTP/1.0 302 Found
Location: XXX
...

Now do a second request on the URL passed in the Location header and so on.

Ferdinand Beyer
Grand stuff. Out and about at the moment but i'll check tomorrow and hopefully i'll get to the bottom of it.
Doozer1979
+1  A: 

Just carefully check your URLMappings configuration:

YOUR_APP/grails-app/conf/UrlMappings.groovy

Common case:

You configured request to be handled like this:

"/anything" (controller:"someController")

So without action, request will be handled by default one, "index". "index" action usually redirects to "list", and "list", in some cases redirect back to "index"

There is your loop.

Good luck

Nenad
Many thanks Nenad
Doozer1979