Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy webapp manually with Tomcat (ie autoDeploy=false, noDeployOnStartup=false)

I'm trying to deploy several web applications to tomcat 6.x, and I've turned off autoDeploy and onDeployStartup because I want to manually register these apps and map them to URLs not based on the names of their war files.

I've put the following context file in $catalina.home/conf/Catalina/localhost:

<Context path="" docBase="web-1.0-SNAPSHOT.war" debug="1">
</Context>

And I put the war file under $catalina.home/webapps, but when I startup tomcat nothing gets deployed. I don't even see any error messages about the context files I created. Or any print outs saying anything is wrong.

What's the problem? I've read the documents which outlines autodeploy a lot, but is very sketchy on details of how to do this outside of autodeploy.

like image 430
chubbsondubs Avatar asked Oct 07 '22 01:10

chubbsondubs


2 Answers

So the details about how autoDeploy works, and alternative deployments is only really discussed here.:

http://wiki.apache.org/tomcat/HowTo#How_do_I_make_my_web_application_be_the_Tomcat_default_application.3F

I don't know why tomcat makes this so complicated. If you turn off autoDeploy your only option is to modify the server.xml and add your contexts there. You can't externalize the definitions of your contexts which seems convoluted way to deploy things. If I'm going to take the time to drop a XML config file I should be able to control the URL it's mounted to and the docBase. Just make it straight forward because Jetty does.

like image 72
chubbsondubs Avatar answered Oct 10 '22 03:10

chubbsondubs


Try the following steps

Shutdown the tomcat

Copy web-1.0-SNAPSHOT.war to webapps folder.

Deploy the webapp.

Now there is a folder named web-1.0-SNAPSHOT inside webapps.

go to conf/server.xml

Add the following entries

<Context path="/abc" docBase="web-1.0-SNAPSHOT" debug="1"></Context>

The docbase doesn't have the .war extention. When web-1.0-SNAPSHOT.war is deployed there will be a directory web-1.0-SNAPSHOT inside webapps. The docbase should point to this directory.

Please make sure that Context tag is within the

<Host>  </Host> tag 

<Host>
    <Context path="/abc" docBase="web-1.0-SNAPSHOT" debug="1"></Context>
</Host>

After editing server.xml you have to restart tomcat server to reflect the changes. Now you can find your webapp at

localhost:8080/abc

Hope this helps

like image 44
Konza Avatar answered Oct 10 '22 02:10

Konza