开发者

Create war file from configuration file

开发者 https://www.devze.com 2023-02-27 16:51 出处:网络
In the current system set up I have several configuration files stored in the conf/Catalina/localhost directory. For example images.xml:

In the current system set up I have several configuration files stored in the conf/Catalina/localhost directory. For example images.xml:

<Context path="/images" docBase="/home/user/images" debug="0" privileged="true" />

This allows to link to files inside this directory, for example: http://localhost:8080/images/image.jpg

But when the mapped drive is on a network location it happens that the connection to the drive is lost. Because Tomcat is then unable to reach the destination the configuration is automatically undeployed. Because of the real web application running on this 开发者_运维知识库server I don't want to change this Tomcat settings.

So the question is, can I include this configuration in a WAR file? This would make it easier to redeploy and probably allow me to bundle configurations?


The specific configuration tells tomcat to load the web app from a specified directory (outside of tomcat's default). This is tomcat specific configuration so even if it was possible to bundle this config in war (which i don't think you can) I'd recommend not to go that path.

The better way would be bundle to your images as a exploded war file (so that you can add remove images while tomcat is running)and deploy it in the tomcat. As i understand you want to keep you images in separate network drive whose connectivity is intermittent. In that case it makes sense for tomcat to undeploy the context when the resource is not available.


if you create a war file called images.war and place it in your webapps/ROOT directory then this will automatically be mapped onto the context path images (based on the war file name). So you can do it this way. Make sure you also include a deployment descriptor (web.xml) -- details here: http://download.oracle.com/docs/cd/E13222_01/wls/docs81/webapp/web_xml.html

Sorry you are spot on with your comment -- serves me right for not paying attention! It is indeed the webapps directory and not webapps/ROOT as I copied and pasted above.

0

精彩评论

暂无评论...
验证码 换一张
取 消