views:

362

answers:

2

I'm having an issue getting Appstats to work correctly. Using /appstats or /appstats/stats ends up in an infinite loop that keeps redirecting back to /appstats/stats. This results in a 404 error saying the page isn't redirecting properly. Any idea what the issue is?

Below are the relevant lines in my web.xml. This is basically the same from the documentation here.

<servlet>
    <servlet-name>appstats</servlet-name>
    <servlet-class>com.google.appengine.tools.appstats.AppstatsServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>appstats</servlet-name>
    <url-pattern>/appstats/*</url-pattern>
</servlet-mapping>

<filter>
    <filter-name>appstats</filter-name>
    <filter-class>com.google.appengine.tools.appstats.AppstatsFilter</filter-class>
    <init-param>
        <param-name>logMessage</param-name>
        <param-value>Appstats available: /appstats/details?time={ID}</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>appstats</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<security-constraint>
    <display-name>appstatsConstraint</display-name>
    <web-resource-collection>
        <web-resource-name>appstatsCollection</web-resource-name>
        <url-pattern>/appstats/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>admin</role-name>
    </auth-constraint>
</security-constraint>

Here are the relevant lines in my appengine-web.xml. I've tried using both /appstats/stats and /appstats and they both have the same issue.

<admin-console>
    <page name="Appstats" url="/appstats/stats" />
</admin-console>

Below are the http headers showing the infinite redirect loop:

http://mysite.appspot.com/appstats/stats

GET /appstats/stats HTTP/1.1
Host: mysite.appspot.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:
1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Cookie: USER_LOCALE=en_US; JSESSIONID=POTIUPPpEmjHZoaNDWOSTA;
ACSID=AJKiYcHiwT8jH7e01V9O5iFu3kpBhDd3k3oBwwxylv5u0DbJ-
utvdpsgdb4Xim2WXwobkJmgTGGljvuh94_yVQ__-
VPnBsTtUAhRjSyZ2Lv3G7oUHAxTsCWHJIMChGT3-
XUyUNx8wxwvJisL_RTXH8Hc4TTLh_rVHm2k8gk8kgdbVZXexSV0K-
a3coELTecWIBolt0qLd5L-5vALm382KsqbHorPXqoZMPTvR_06g_mR1cbmF2Ihnk6YhP7no58BNpESM9HvFyKNKXODo39hF4oaZCcW0Q9TBqUMgsrBqlcIh3-
VvC7qvH0n_nAtrLTBbK_swnOFvCDcaf3whT9ty0CJ0VRNuNqIPOLHIeQAMgwXUNMr89P64EsgmuyONHR67glCQXEPOGXIaT1vcBJFwFoeNUqjdp824fHvoVhaL7Xlav-
LTIFuM3f_ymHLmibk57PRuXUYEaAG

HTTP/1.1 302 Found
Location: http://mysite.appspot.com/appstats/stats
X-AppEngine-Estimated-CPM-US-Dollars: $0.645553
X-AppEngine-Resource-Usage: ms=18965 cpu_ms=27884 api_cpu_ms=0
Set-Cookie:
ACSID=AJKiYcF_YA7PB18b3T5OO7vEMo31f1hFhO8xKqFRiBUGrCr4YABAAyugZXcDfKMOM-
r0FiK8xlOPfQWx3tOWIJ6ueOqK89X8M9YfHIs8WKUcSs6PwNZSKV0HKxvbqeWxfZI_cpo2YoS73s_RPlyEvjaYLOf6iXPpWeYyKTAbSqPOEBnVnTk3oso6ur66CIj3FnN8vsHfbanqY4sbaRsNj9pLjWZco0quYLOK1fd4wRZx_oAvk3jOlfAj7BZ7p9L1bO8oVCMpVn19cwT6zvO2-9RSjfiOPAacw7Cg0MT30r7Fr7SCj7VcSPAye4lc7tb9KL9ztZEk0xbEX-9vC6vHM_VfPJ54Kb_FycxE6lACsKTE4hj0bOa2-2quaOP0NSxfoH9ozLlQQCsGhpWBnlu__W06D0GqDqxcDUu2HocYqWuLi91aoa-
aRTkqB_qo4aAa3OvHeKoFgwrS; expires=Mon, 12-Apr-2010 19:41:49 GMT;
path=/
Date: Sun, 11 Apr 2010 19:42:08 GMT
Pragma: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Cache-Control: no-cache, must-revalidate
Content-Type: text/html
Server: Google Frontend
Content-Length: 0
----------------------------------------------------------
http://mysite.appspot.com/appstats/stats

GET /appstats/stats HTTP/1.1
Host: mysite.appspot.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:
1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Cookie: USER_LOCALE=en_US; JSESSIONID=POTIUPPpEmjHZoaNDWOSTA;
ACSID=AJKiYcF_YA7PB18b3T5OO7vEMo31f1hFhO8xKqFRiBUGrCr4YABAAyugZXcDfKMOM-
r0FiK8xlOPfQWx3tOWIJ6ueOqK89X8M9YfHIs8WKUcSs6PwNZSKV0HKxvbqeWxfZI_cpo2YoS73s_RPlyEvjaYLOf6iXPpWeYyKTAbSqPOEBnVnTk3oso6ur66CIj3FnN8vsHfbanqY4sbaRsNj9pLjWZco0quYLOK1fd4wRZx_oAvk3jOlfAj7BZ7p9L1bO8oVCMpVn19cwT6zvO2-9RSjfiOPAacw7Cg0MT30r7Fr7SCj7VcSPAye4lc7tb9KL9ztZEk0xbEX-9vC6vHM_VfPJ54Kb_FycxE6lACsKTE4hj0bOa2-2quaOP0NSxfoH9ozLlQQCsGhpWBnlu__W06D0GqDqxcDUu2HocYqWuLi91aoa-
aRTkqB_qo4aAa3OvHeKoFgwrS

HTTP/1.1 302 Found
Location: http://mysite.appspot.com/appstats/stats
X-AppEngine-Estimated-CPM-US-Dollars: $0.002243
X-AppEngine-Resource-Usage: ms=64 cpu_ms=93 api_cpu_ms=0
Date: Sun, 11 Apr 2010 19:42:08 GMT
Content-Type: text/html
Server: Google Frontend
Content-Length: 0 
+2  A: 

It turns out this was an issue with the URL rewrite filter configuration that I also had in my web.xml. I had to ensure that no rules matched /appstats/*. I edited my rewrite urlrewrite.xml to below.

<urlrewrite>
    <rule>
        <from>^(?!/appstats/)/(.*)$</from>
        <to last="true">/app/$1</to>
    </rule>
</urlrewrite>

/app/* is my Spring dispatcher servlet mapping.

Taylor Leese
A: 

Thank you for posting the answer. I have been hunting the google docs for the last one hour trying to figure out whats wrong and then I realized upon reading your post that I have the damn urlrewrite filter setup! Cheers!

Ganesh Krishnan
No problem, glad to know I'm not the only one who screwed this up. :-)
Taylor Leese