wood burning stoves*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Can you choose where to put the WAR file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Can you choose where to put the WAR file?" Watch "Can you choose where to put the WAR file?" New topic
Author

Can you choose where to put the WAR file?

Al Pearson
Greenhorn

Joined: Dec 19, 2001
Posts: 18
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
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
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
satya uppaluri
Greenhorn

Joined: Oct 16, 2002
Posts: 21
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
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
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

Joined: Dec 19, 2001
Posts: 18
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
Maha Annadurai
Ranch Hand

Joined: Oct 27, 2002
Posts: 87
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
 
jQuery in Action, 2nd edition
 
subject: Can you choose where to put the WAR file?
 
Similar Threads
How to create a war file
files in WEB-INF/classes not found?
SEVERE: Error listenerStart
Make Tomcat go
Can't write Context element properly