tags:

views:

52

answers:

2

I was wondering what would be the best practice to deploy a maven packaged WAR file to tomcat. Using maven release plugin I get a versioned war file for my project eg: myservice-1.0.0.war

I would like to deploy it to tomcat so that I can access it as follows eg: http://localhost:8080/myservice

By default tomcat explodes the war file as a directory with a name myservice-1.0.0 under CATALINA_HOME/webapps. But I want to to explode the war as a directory with a name myservice for the reasons mentioned above.

I know I can simply rename myservice-1.0.0.war >> myservice.war and then deploy it in Tomcat.

I wanted to find out what others do?

+1  A: 

I would do it by mentioning myservice as artifactId and final name and using maven cargo plugin to deploy to tomcat. http://cargo.codehaus.org/Maven2+Plugin+Tips

Ankit
thanks. I do use artifact id as myservice but I also need to version the project which in my case is 1.0.0What tip in particular are you referring to in the link you provided?
andthereitgoes
ok... in build tag there is an option to provide finalName which becomes the name of war. Did you try setting it?
Ankit
oh cool thanks. I forgot about that. Yes, that's an option, I could definitely try that. I am still interested to find out how others approach it for their production builds.
andthereitgoes
+1  A: 

You can package file /META-INF/context.xml with content like this:

<?xml version="1.0"?>
<!DOCTYPE Context>
<Context path="myapp">
</Context>

See documentation at http://tomcat.apache.org/tomcat-5.5-doc/config/context.html

Eugene Kuleshov