chubbsondubs
chubbsondubs

Reputation: 38706

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.

Upvotes: 7

Views: 15508

Answers (4)

Doesystem
Doesystem

Reputation: 61

Example code

<Host name="localhost"  appBase="webapps"
        unpackWARs="true" autoDeploy="false" deployOnStartup="false">


    <Context path="/howto-prepareexam" docBase="howto-prepareexam" debug="1"></Context>

    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
           prefix="localhost_access_log" suffix=".txt"
           pattern="%h %l %u %t &quot;%r&quot; %s %b" />

  </Host>

Then restart tomcat

Upvotes: 0

chubbsondubs
chubbsondubs

Reputation: 38706

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.

Upvotes: 3

Konza
Konza

Reputation: 2163

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

Upvotes: 2

user890904
user890904

Reputation:

Setting deployonstartup to false tells tomcat not to deploy apps on startup. I think its enough to turn autodeploy off. so maybe try the following in the Host in server.xml: autoDeploy="false" deployOnStartup="true".

Upvotes: 1

Related Questions