简体   繁体   English

Tomcat 7符号链接到War文件

[英]Tomcat 7 symbolic link to war file

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. 我想在tomcat的webapps目录中有一个符号链接,该链接指向文件系统中其他位置的war文件,并且我希望将该war文件用作默认的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. 我的主目录〜/ tomcat / webapps中有一个文件夹。 The owner is tomcat7. 所有者是tomcat7。 In this folder, I have my war file, myapp-1.0.war. 在此文件夹中,我有战争文件myapp-1.0.war。

In my /var/lib/tomcat7/webapps directory, I have a symbolic link: 在我的/ var / lib / tomcat7 / webapps目录中,我有一个符号链接:

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

In my /etc/tomcat7/server.xml, I have: 在我的/etc/tomcat7/server.xml中,我有:

<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. Tomcat一开始没有任何抱怨,但我的应用无法访问。 [host]:8080/rest/ returns 404, where it would normally take me to the home page. [host]:8080 / rest /返回404,通常它将带我到主页。

I partially want to do this to abstract out the version number from my war file. 我部分想这样做,以便从我的war文件中提取版本号。 Any ideas why this is not working, or what I'm doing wrong? 任何想法为什么这不起作用,或者我做错了什么?

Thanks. 谢谢。

I found the problem. 我发现了问题。 The symlink in the webapps directory needs to have a .war extension. webapps目录中的符号链接必须具有.war扩展名。 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: 我还能够缩短docBase属性的值,如下所示:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM