I have the following configuration running on Tomcat 8.0.20:
C:\tomcat
conf
server.xml
context.xml
webapps
app
app2
......
C:\external
app3
web
app4
web
app5
web
In context.xml I have <Context crossContext="true"> .... </Context>
And in server.xml:
..........
<Host name="host.com" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Context
cachingAllowed="false"
docBase="C:\external\app3\web"
path=""
crossContext="true"
reloadable="true" />
<Context
cachingAllowed="false"
crossContext="true"
docBase="C:\external\app4\web"
path="/app4"
reloadable="true" />
<Context
cachingAllowed="false"
crossContext="true"
docBase="C:\external\app5\web"
path="/app5"
reloadable="true" />
</Host>
Obtaining the Context of /app
, /app2
or /app5
from /app4
works as espected:
request.getServletContext().getContext("/app")
is not null.
However, requesting the Context of /app3
(with context path /
).
Any idea why getContext("/")
is null?
As it turned out, it's a regression in tomcat after version 8.0.15
Filed a bug report here
Reverted tomcat to 8.0.15 and it's working now....