I’m providing a <Parameter name="javax.servlet.context.tempdir" value="${catalina.base}/my_temp" override="false"/> inside the <Context> node of Tomcat’s context.xml file.
I know it’s being seen on server start up because of this log message:
INFO: Creating LRUMap cache instance using parameters: {javax.servlet.context.tempdir=D:\{omitted}\tmp0\my_temp, org.richfaces.resourceMapping.enabled=true, javax.faces.PROJECT_STAGE=Development, javax.faces.SKIP_COMMENTS=true}
However, when stepping over code in the RichFaces FileUploadFacesContextFactory.getTempFilesDirectory() method, a call to servletContext.getAttribute("javax.servlet.context.tempdir") (where servletContext is an instance of org.apache.catalina.core.ApplicationContextFacade) gives the value D:\{omitted}\tmp0\work\Catalina\localhost\_.
I was under the impression (from the Tomcat Docs on context parameters) that setting override="false" should keep any application from providing an alternative value for this parameter.
Is this expected behaviour? Configuration error on my part?
Your misunderstand what
<Parameter>does: it sets a ServletContext “init-param” in the same way that<context-param><param-name>javax.servlet.context.tempdir</param-name>...</context-param>would do in yourWEB-INF/web.xml.RichFaces is looking at a formal Context attribute, which is different. If you want your web-app to copy an init-param to a context-attribute upon startup, you’ll want to create a
ServletContextListenerthat executes code similar to the following when your webapp starts:Note that changing the value of the
tmpdirmay not be a great idea: it may interfere with the container’s ability to manage your resources.