Reading-eScience-Centre / edal-java

Environmental Data Abstraction Layer libraries
Other
39 stars 30 forks source link

404 on Save configuration #54

Closed rjdave closed 8 years ago

rjdave commented 8 years ago

When I use the admin page to update datasets or server setting and info I get a "404 - The requested resource is not available." when I click the "Save configuration" button. However, the changes appear to be saved when I go back and look at the admin page again. The URL that displays when I get the 404 error is:

http://tds.marine.rutgers.edu:8081/ncWMS2/admin/updateConfig

I am using ncWMS v2.1.2-SNAPSHOT on tomcat 8.0.32 with java 1.8.0_74.

guygriffiths commented 8 years ago

I'm not currently able to reproduce this - can you give me some more information about your configuration (e.g. what browser you're using, how exactly you're doing it, does it happen with both "Save configuration" buttons etc.)

The "Save configuration" button should just submit the config form to .../admin/updateConfig, but it uses HTTP POST so it's strange that your browser is being redirected there.

rjdave commented 8 years ago

I tried on several different browser/OS combinations and the only combination that worked was IE/Edge (on windows of course). Other combos I tried were Chrome, Firefox, and Safari on OS X, Forefox and Chrome on Windows, and Firefox on Linux. (The domain, .marine.rutgers.edu, was omitted from the URLs to make it a bit shorter).

If I watch the access log for the combination that works (IE/Edge), I see the following lines:

192.168.10.15 - robertson [20/Apr/2016:12:50:43 -0400] "POST /ncWMS2/admin/updateConfig HTTP/1.1" 302 - "http://tds/ncWMS2/admin/" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko" 15
192.168.10.15 - robertson [20/Apr/2016:12:50:43 -0400] "GET /ncWMS2/admin/ HTTP/1.1" 200 31394 "http://tds/ncWMS2/admin/" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko" 8

Note the removal of updateConfig from the GET line.

There are two behaviors for the failing browsers. The first is the one I reported complaining about "resource not available" and happens with all Firefox combinations. The access log says:

192.168.10.15 - robertson [20/Apr/2016:13:15:40 -0400] "POST /ncWMS2/admin/updateConfig HTTP/1.1" 302 - "http://tds/ncWMS2/admin/" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0" 14
192.168.10.15 - robertson [20/Apr/2016:13:15:40 -0400] "GET /ncWMS2/admin/updateConfig HTTP/1.1" 404 992 "http://tds/ncWMS2/admin/" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0" 1

You'll notice that updateConfig is not stripped off.

The third behavior happens with Chrome and Safari. I click the submit and get a blank page with the URL http://tds/ncWMS2/admin/updateConfig but no output to the screen (blank white page) and when I look at the logs I see this one line:

192.168.10.15 - robertson [20/Apr/2016:13:19:59 -0400] "POST /ncWMS2/admin/updateConfig HTTP/1.1" 302 - "http://tds/ncWMS2/admin/" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36" 15

If I then click in the address bar that has the URL http://tds/ncWMS2/admin/updateConfig and hit enter I get "resource not available" error the following line in the access log:

192.168.10.15 - robertson [20/Apr/2016:13:22:29 -0400] "GET /ncWMS2/admin/updateConfig HTTP/1.1" 404 992 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36" 3

as you would expect. It's also important to note that if I click refresh in this situation instead of clicking the address bar and hitting enter, the browser asks me if I want to resubmit form data. This does not happen with Firefox because refreshing is sent a GET, not a POST.

My first thought is that perhaps the different browsers handle/implement the POST/Redirect/GET pattern differently.

P.S. The same behavior occurs when I take the Apache proxy out of the loop by using the full real URL that only works internally: http://tds.marine.rutgers.edu:8081/ncWMS2/admin/

guygriffiths commented 8 years ago

OK, I've managed to reproduce this now. It seems to be due to Tomcat 8. We've only tested ncWMS2 using Tomcat 7 and the behaviour is different. I'll do some investigating and see if I can find a workaround.

guygriffiths commented 8 years ago

OK, after some experimentation I've figured this out. The issue was that the admin servlet was sending a blank redirect: response.sendRedirect("") (so that refreshing the page will not resubmit the form) In Tomcat <=7, that was redirecting to http://servername:port/ncWMS2/admin whereas in Tomcat 8 it was being treated differently. From the headers it seems that Tomcat 7 was intercepting the redirect and explicitly inserting the full URL into the "Location" header, whereas Tomcat 8 just sends an empty location which gets interpreted differently on different browsers.

The solution therefore was to change the redirect to: response.sendRedirect("./") which works with both Tomcat 7 and Tomcat 8.