Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying context.xml to webapps/[webappname]/META-INF

I'm using Tomcat 6.0.26 and am writing build.xml to deploy war file. The following code is what I have right now, and I need to pack context.xml under /META-INF/ as I wish to have this configuration like #2. I have searched the attribute for the war command, but I couldn't find anything that works like webxml for WEB-INF/web.xml.

So my questions are,

1) Is there an war attribute to place the context.xml under META-INF ?

2) If there isn't such an attribute, what would be the best way to place the context.xml under META-INF for each webapp?

<target name="packwar">
   <war destfile="${appname}.war" webxml="web.xml">
        <lib file="${bin}/myapp.jar"/>
   </war>
</target>

Thank you in advance.

like image 913
c4il Avatar asked Nov 28 '25 08:11

c4il


1 Answers

You should be able to use the metainf nested element of the 'war' task:

The nested metainf element specifies a FileSet. All files included in this fileset will end up in the META-INF directory of the war file. If this fileset includes a file named MANIFEST.MF, the file is ignored and you will get a warning.

Something like this:

<target name="packwar">
   <war destfile="${appname}.war" webxml="web.xml">
        <lib file="${bin}/myapp.jar"/>
        <metainf file="context.xml" />
   </war>
</target>

There is a similar option - 'webinf' - for deploying to the WEB-INF directory.

like image 112
martin clayton Avatar answered Nov 30 '25 21:11

martin clayton