Tomcat response the same every time after initital response
I have a relatively simple spring web application running on tomcat which
returns an xml document. The initial request goes in and I can debug into
my code. However, subsequent requests do not drop into the debugger. I can
make the initial request with either a browser or soapUI, and subsequent
requests (on different browsers/programs/machines) get the same response
as the initial one.
The localhost_access_log is getting populated with every request. However
the log4j file is not getting populated beyond the first request.
I'm using Tomcat 7 and spring 3.1.1. This happens on both the tomcat
deployed within eclipse (used to enable debugging), as well as deploying
it on another tomcat server on linux.
This is similar to another question (Tomcat gives Same Response ) which
never had an accepted answer.
So it doesn't appear to be browser caching (different applications making
requests get the same response), but rather some sort of Tomcat caching.
Any ideas? Here is the server.xml which I believe may be the cause of the
problem somehow, but I don't see any red flags. Also, I'm doing GETs to
the web application, which may be caching somehow on the server side.
Example GET request: http://localhost:8130/bootstrap/xml?environment=dev
It returns a xml document as noted in this RequestMapping:
@RequestMapping(value = "/xml", method =
RequestMethod.GET,produces="application/xml")
Sample Response:
<connection_details env="dev">
<servers>
<server host="localhost" name="auth" port="9876"/>
</servers>
</connection_details>
The issue manifests itself as every request returns the same as the
initial request, even if the environment variable passed into the GET
request changes. This is even if requested from different browsers and
soapUI.
Example of how the response above is created:
private ModelAndView bootstrap(HttpServletResponse response, String
environment) {
Map<String, Object> model = new HashMap<String, Object>();
try {
DOMSource domSource = new DOMSource(documentBuilder.parse(context
.getResourceAsStream(bootstrapXmlFileName)));
model.put("xml", domSource);
model.put("requestedEnvironment", environment);
}
catch (Exception e) {
response.setHeader("ERRORS", e.getMessage());
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return null;
}
return new ModelAndView("bootstrap_connection_selector", model);
}
Then it is passed to an xslt transformation:
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.xslt.XsltView" />
<property name="prefix" value="/WEB-INF/xsl/" />
<property name="suffix" value=".xslt" />
</bean>
Finally the following transformation:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- parameter for the requested location -->
<xsl:param name="requestedlocation"/>
<!-- start template matching on the connection_details element -->
<xsl:template match="/connection_details">
<!-- duplicate the enclosing <connection_details env=xxx" element -->
<xsl:element name="connection_details">
<xsl:attribute name="env">
<xsl:value-of select="@env"/>
</xsl:attribute>
...
<!-- close the <connection_details> element -->
</xsl:element>
</xsl:template>
</xsl:stylesheet>
server.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Server port="8133" shutdown="SHUTDOWN">
<Listener SSLEngine="on"
className="org.apache.catalina.core.AprLifecycleListener"/>
<Listener className="org.apache.catalina.core.JasperListener"/>
<Listener
className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
<Listener
className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<Listener
className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>
<GlobalNamingResources>
<Resource auth="Container" description="User database that can be
updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
name="UserDatabase" pathname="conf/tomcat-users.xml"
type="org.apache.catalina.UserDatabase"/>
</GlobalNamingResources>
<Service name="Catalina">
<Connector connectionTimeout="20000" port="8130" protocol="HTTP/1.1"
redirectPort="8131"/>
<Connector port="8132" protocol="AJP/1.3" redirectPort="8131"/>
<Engine defaultHost="localhost" name="Catalina">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host appBase="webapps" autoDeploy="true" name="localhost"
unpackWARs="true">
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" pattern="%h %l %u %t "%r" %s %b"
prefix="localhost_access_log." suffix=".txt"/>
<Context docBase="em_bootstrap" path="/bootstrap" reloadable="true"
source="org.eclipse.jst.jee.server:em_bootstrap">
</Context></Host>
</Engine>
</Service>
</Server>
No comments:
Post a Comment