6

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.

chubbsondubs
  • 37,646
  • 24
  • 106
  • 138

4 Answers4

3

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.

chubbsondubs
  • 37,646
  • 24
  • 106
  • 138
2

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

Konza
  • 2,143
  • 17
  • 30
  • I'll give you an up vote because what you describe is one way to make it work, but I think I found the comprehensive explanation of why you have to do this if you turn off autoDeploy. And alternatives so I can keep my contexts external to server.xml – chubbsondubs Nov 08 '12 at 15:02
  • why don't you post it here? It will be good for others and myself. – Konza Nov 08 '12 at 15:36
  • I already did post another answer with the link to the information I found. If you skip down to the Addendums and Method 2.1 and 2.2 sections those are probably the best explanations I seen for what it means if you turn off autoDeploy/deployOnStartup. – chubbsondubs Nov 08 '12 at 16:29
1

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".

  • This might be the solution. Restarting Tomcat on production deploy is a good solution because of well-known PermGen space errors. I've ended up with one Tomcat for each application. – Piotr Gwiazda Nov 07 '12 at 23:21
  • I had deployed with deployOnStartup="true" already and it just does exactly what autoDeploy="true" does and I don't have control over mapping URLs to my war files. I have specific URLs I want to put the wars on that don't derive from the names of the war files. That's really the problem I'm trying to solve. So I don't think turning on either autoDeploy or deployOnStartup is a solution. – chubbsondubs Nov 07 '12 at 23:24
  • that then is another question that can be opened on SO. how to deploy to a different path than the name of the war file. but in this question the problem is app not loading on tomcat start. it won't if both are false. –  Nov 07 '12 at 23:26
  • http://stackoverflow.com/questions/9517182/deploying-war-file-to-tomcat-with-a-different-path –  Nov 07 '12 at 23:33
  • It's not really another question because it's my motivation, and it really doesn't answer the other questions I had which is how can I debug deploying of context fragments because according to the docs I'm putting them in the right directory, but tomcat doesn't see them. And their solutions are kinda just hacks working around autoDeploy's lack of control over the URL. – chubbsondubs Nov 08 '12 at 02:57
0

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

Doesystem
  • 61
  • 1
  • 4