On 28/08/2009 09:57, Jan Jonas wrote:
I have a very annoying problem with tomcat 6:
ServletContext.getContext() always returns null if I call the method from the "root" context, i.e.
the context I have defined with path="/" in my server.xml. I also tried setting path=""
(I read that this could fix problems in tomcat 5 - I'm using tomcat6 but a thought it might help).
Here are the context definitions of my server.xml:
<Context path="/context2" docBase="/absolute/path/to/a/folder/"
/>
<Context path="/ " docBase="..." crossContext="true"
reloadable="true"/>
Eww.
The ROOT webapp is defined with path="" not path="/"
Is there a particular reason why you're defining your Context in server.xml?
It looks like you've got an config copied from an old Tomcat. These days
it's generally encouraged to define a Context in a META-INF/context.xml
file in your webapp instead, (unless there are extenuating
circumstances) - you don't then need to define 'path' or 'docBase',
Tomcat handles the rest.
I also tried defining both contexts with crossContext="true".
If a change the path from the second context to something else than "/" or ""
everything works fine. Is this a tomcat bug?
No, I don't think so.
My workaround now is to use apache's mod_rewrite to handle requests on "/".
Probably just need to tweak your config instead.
p
Regards
Jan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org