Stephen,
On 6/19/24 13:55, Stephen Tenberg wrote:
Hello I have scoured the web trying to get symlinks working for jsp pages
or folders in Tomcat 9 using Ubuntu 20.04. Here is how to repeat the issue,
and what I have tried.
1. Create a new folder in webapps, say "foo"
2. Put HelloWorld.jsp there
3. (I restarted Tomcat just in case) Verify it works at
localhost:8080/foo/HelloWorld.jsp
4. Put a soft symlink there: ln -s /opt/tomcat/webapps/foo/HelloWorld.jsp
/opt/tomcat/webapps/foo/Link.jsp
5. (restart) Verify that localhost:8080/foo/Link.jsp soft fails with
nothing in the log as if it does not exist.
WHAT I TRIED:
First I put this in the default host "localhost" in server.xml:
<Context path="" reloadable="true" docBase="foo">
<Resources allowLinking="true" cacheMaxSize="51200">
</Resources>
</Context>
Why path="" instead of path="foo"?
In fact... why bother with a <Context> element at all? The presence of
the "foo" directory will automatically deploy an application on /foo.
Yes, in order to "allow linking" you will need a <Context> to set it on,
but that should be under webapps/foo/META-INF/context.xml and not in
conf/server.xml. Yes, you can put it in server.xml, but you should not
do that for a few reasons.
<Context path="/ROOT" docBase="ROOT"/>
Yuck. Now you have an application deployed into "/ROOT" as well as ""
(the default ROOT application, mounted on /)
This achieves the objective of making "foo" the default so now I can just
use localhost:8080/HelloWorld.jsp
I think you must have copy/pasted incorrectly, but nothing of what you
put above would allow /HelloWorld.jsp to run the JSP in "foo".
However "allow linking" is silently ignored. I also tried editing
context.xml and adding to the context:
<Resources allowLinking="true" />
<Resources cacheMaxSize="51200" />
This ... is confusing at best because you have two elements in there.
I'm not sure what will happen if you define it twice. Maybe the second
one overwrites the first? If that's true, it might explain why it
wouldn't work.
Both of these solutions were gleaned from reading the documentation and
Google searches, and I seem to be stuck here.
For now I cannot install a later version of Tomcat (using Amazon Java 8
Coretto) or remove the symlinks as they are required by an existing
application.
Any thoughts are greatly appreciated.
First: simplify. Put everything into your application and give it the
name AND context-path you want, for example webapps/foo and everything
is in there.
There is really only one place where symlinking can be configured at
all, which is <Resources>. Put your <Context> in
webapps/foo/META-INF/context.xml and use a single <Resources> element
with an appropriate configuration.
Remove everything else.
Restart and see what happens when you request /foo/Link.jsp
-chris
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org