Tomcat 7 symbolic link to war file

别来无恙 提交于 2019-12-06 13:51:36

问题


I would like to have a symbolic link in tomcat's webapps directory that points to a war file at another place in my file system, and I would like that war file to be served as the default webapp. I have pieced together the following solution, but the app is not accessible from the browser.

I have a folder in my home directory ~/tomcat/webapps. The owner is tomcat7. In this folder, I have my war file, myapp-1.0.war.

In my /var/lib/tomcat7/webapps directory, I have a symbolic link:

myapp -> /home/[me]/tomcat/webapps/myapp-1.0.war.

In my /etc/tomcat7/server.xml, I have:

<Context docBase="/var/lib/tomcat7/webapps/myapp" path="" reloadable="true" allowLinking="true"/>

Tomcat starts with no complaints in the logs, but my app is not accessible. [host]:8080/rest/ returns 404, where it would normally take me to the home page.

I partially want to do this to abstract out the version number from my war file. Any ideas why this is not working, or what I'm doing wrong?

Thanks.


回答1:


I found the problem. The symlink in the webapps directory needs to have a .war extension. So, instead of:

myapp -> /home/[me]/tomcat/webapps/myapp-1.0.war

It should be:

myapp.war -> /home/[me]/tomcat/webapps/myapp-1.0.war

I was also able to shorten the value of the docBase attribute as below:

<Context docBase="myapp" path="" reloadable="true" allowLinking="true"/>


来源:https://stackoverflow.com/questions/27848047/tomcat-7-symbolic-link-to-war-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!