|
From: <jue...@we...> - 2003-05-05 07:57:31
|
Hi Chris, Spring web users,
Thanks for the report! Admittedly, I only testet this on Windows and =
didn't think about Unix path names (should have come to my mind, =
though). I've changed the default paths =
("/WEB-INF/applicationContext.xml", =
"/WEB-INF/<servlet-name>-servlet.xml") to clear relative paths now, =
omitting the leading slash.
On the occasion, I've made config lookup more flexible, allowing not =
only for a servlet context init param "configLocation" for the root =
context, but also "configLocationPrefix" and "configLocationSuffix" for =
namespaced contexts (defaults are "WEB-INF/" and ".xml").
Note that the trailing "-servlet" comes from the FrameworkServlet's =
namespace handling and is thus part of the namespace. To override the =
namespace for a specific servlet, just set a servlet init parameter =
"namespace" to the desired value.
Default initialization should still behave like before, and often you =
won't need any customization. But if you like to, you can now customize =
config lookup like this:
<web-app>
<context-param>
<param-name>configLocationPrefix</param-name>
<param-value>WEB-INF/myControllers/</param-value>
</context-param>
<context-param>
<param-name>configLocation</param-name>
<param-value>WEB-INF/myRoot.xml</param-value>
</context-param>
<listener>
=
<listener-class>com.interface21.web.context.ContextLoaderListener</listen=
er-class>
</listener>
<servlet>
<servlet-name>test</servlet-name>
=
<servlet-class>com.interface21.web.servlet.ControllerServlet</servlet-cla=
ss>
<init-param>
<param-name>namespace</param-name>
<param-value>myTest</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
</web-app>
This should look up the root context file in "WEB-INF/myRoot.xml", and =
the ControllerServlet context file in =
"WEB-INF/myControllers/myTest.xml".
Regards,
Juergen
-----Original Message-----
From: Chris Smith [mailto:ch...@lo...]
Sent: Sunday, May 04, 2003 3:02 PM
To: spr...@li...
Subject: [Springframework-developer] spring-web broken on unix
Hi everyone,
Juergen, I've just found a problem with the changes you made to=20
XmlWebApplicationContext recently.
When loading the bean config in getInputStreamForBeanFactory(), it=20
delegates to the base class AbstractApplicationContext's=20
getResourceAsStream() method. For a config location such as=20
"/WEB-INF/test-servlet.xml", that method will try to load it using a=20
URL, fail, catch the MalformedURLException, then see if the path is=20
relative or absolute. If relative, it loads it using the overridden=20
getResourceByRelativePath().
That all works fine on windows, but on unix, "/WEB-INF/test-servlet.xml" =
is considered an absolute path because it starts with a slash. The=20
context fails to load because it tries to load it as a File rather than=20
from the servlet context.
The problem is that we can't tell whether a config location like=20
"/WEB-INF/test-servlet.xml" is a path to a file or a resource in the=20
servlet context. I couldn't find it in a brief flick through the=20
servlet spec, but I didn't think servlets were allowed to access=20
resources outside the servlet container. If that's the case, then=20
XmlWebApplicationContext ought to override getResourceAsStream() with an =
implementation that always loads from the servlet context.
Regards,
Chris
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|