• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Can you choose where to put the WAR file?

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In his article Deploying Web Applications to Tomcat, James Goodwill writes:
The steps required to "WAR-up" your /onjava web application and deploy it are as follows:
1. Change to the root directory of your web application. In this case the root directory would be TOMCAT_HOME/webapps/onjava/.
2. Archive the web application:
jar cvf onjava.war .
3. Copy the resulting WAR file, onjava.war, to the TOMCAT_HOME/webapps directory.
Whereas in the Sybex cert book, it says (p.119): The WAR file is usually stored in the context directory. So, in the previous step 3, we would copy it to TOMCAT_HOME/webapps/onjava.
So who is right, or are they both right, depending on how you jar up?
Alan
 
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They are both right.
When you deploy a WAR file in Tomcat, you put it underneath the webapps directory (webapps/onjava.war). However, when you deploy a web application as a directory, the contents of that directory needs to go underneath webapps/context (webapps/onjava).
HTH
Simon
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
you can place your wars in any orbitary location you want.only thing is you have to let tomcat know where it is to deploy properly.you have to give absolete path of the your war file.
however 'TOMCAT_HOME/webapps' is the default path of webapplications. so every thing placed there will be referenced relitive to that directory so you dont need to give path.
this concept is same for any application server not just tomcat.
please look at the documentation at http://jakarta.apache.org/tomcat/tomcat-4.0-doc/manager-howto.html
 
Simon Brown
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you take a look at the server.xml file in the TOMCAT_HOME/conf directory you'll see how to set up these types of mappings between web applications and the directory in which they reside. For simplicity, you're often best off using the default webapps directory though.
Cheers
Simon
 
Al Pearson
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In server.xml, I changed:
[Context path="/onjava" docBase="onjava" debug="0" reloadable="true" /]
so that docbase="onjava.war" and it's working ok.

:-)thanks Simon and Satya (the link to the /manager was useful
 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just wanted to share my experience which I learnt by making mistake.
When you want to make the war file you have to go INSIDE your context dir and give the jar command.
Otherwise, if you just stay one dir above of your context dir and make the jar command , the war file will have 2 dirs with the same name one inside another like this. canopy\canopy\[all your contents]
Then your app will not work from war file.

Regards,
Maha Anna
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic