tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Willemin" <>
Subject Symlinks inside WEB-INF/classes not working for me
Date Tue, 14 Jul 2009 00:08:20 GMT
Tomcat 6.0.16
Linux 2.6.18
JDK 1.6.0_05

Imagine a webapp like this:
-web.xml (of course)

If I want to load ConfigFile.txt into an InputStream from inside my
webapp, all I have to do is this:

InputStream configStream =

In some cases, I may want to run multiple instances of the application but
have them share one copy of the configuration file. The idea is that I
only want to have to maintain one version of the config file per Tomcat
and have all the webapps use the same copy. If I put ConfigFile.txt inside
/tmp, for instance, this works fine:

InputStream configStream = new FileInputStream("/tmp/ConfigFile.txt");

But what I tried doing was, symbolically linking all the different webapps
to one copy of the file. In other words,
tomcat/webapps/myapp1/WEB-INF/classes/ConfigFile.txt and
tomcat/webapps/myapp2/WEB-INF/classes/ConfigFile.txt would just be
symlinks to /tmp/ConfigFile.txt.

When I do this, the input stream comes up null:
InputStream configStream =

I thought that symlinks were just treated like files, and that this should
just work. I stepped through org.apache.catalina.loader.WebappClassLoader
in the Eclipse debugger and I can't see anything that would obviously
prevent symlinks from working. But the only time that the ConfigFile.txt
shows up in the resourceEntries Map as a ResourceEntry is when I have the
file physically inside WEB-INF/classes - never when it is only a symlink.

I have googled many combinations of
java/linux/classloader/tomcat/symlink/symbolic link/classpath and not
found anything quite like this yet.

Any ideas?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message