File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes no Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "no "war" file created when we deploy a servlet through tomcat ?" Watch "no "war" file created when we deploy a servlet through tomcat ?" New topic
Author

no "war" file created when we deploy a servlet through tomcat ?

abhay jain
Ranch Hand

Joined: Jun 03, 2011
Posts: 130
is that correct that there is no "war" file created when we deploy a servlet through Tomcat ?

.. then why it created when we use sun deployer tool ?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12671
    
    5
Deploying a web application by means of a WAR file is optional.

Creation of a WAR can be done by your IDE or a separate tool, Tomcat has nothing to do with creation of a WAR.

Bill

Java Resources at www.wbrogden.com
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15624
    
  15

Dang it Bill, Now you've gone and made me RTFM!

This is what the JEE 5 spec says about deployment in Section EE.8.4 (Deployment)

Any Java EE product must be able to accept a Java EE application delivered
as a .ear file or a stand-alone Java EE module delivered as a .jar, .war, or .rar
file (as appropriate to its type).


I think that what Abhay was originally asking wasn't really why is no WAR file created, but why no exploded WAR directory was created. Not totally certain, because he was asking about things as though they occurred in the opposite order that they really do.

Tomcat, as well as quite a few other appservers, allows deployment of webapps in "Exploded WAR" format, which is simply the set of directories and files you'd get if you unZIPped a WAR file. Since Tomcat isn't full-stack, it doesn't deal in jar, ear or rar deployables, so I won't mention them further.

However. this is just a convenience. Nowhere in the JEE spec will you find reference to exploded WARs. Officially, to be deployable, a JEE webapp has to be a single WAR file (or EAR, or whatever). Furthermore, Tomcat is under no obligation to actually explode deployed webapps. The option is turned on by default, but it can be turned off or even not done because of how the war was deployed, and I do have some production webapps that don't explode their WARs, in fact.

So just to set the record straight:

A. Tomcat, like other JEE webapp servers does not produce, WARs, it consumes them (as you pointed out). Furthermore, it can work with WARs in their original form, explode them, or accept them in pre-exploded form.

B. IDEs and build utilities such as Ant and Maven can build deployable WARs. I'm not familiar with the Sun deployer tool, but assuming that it lives up to its name, the Sun deployer tools would not be building WAR files, it would be consuming them, bundling them with their corresponding appserver-specific deployment descriptor (if needed), and then forwarding the results through a suitable deployment mechanism (such as JSR-88) into Tomcat. Whether Tomcat then explodes the deployed WARs, like I said, is ultimately Tomcat's decision, although it's possible that the Sun deployer tool's specific deployment processes influence Tomcat's decision.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: no "war" file created when we deploy a servlet through tomcat ?
 
Similar Threads
EAR File in JBOSS
What can cause a .war file not to show/load?
Tomcat Mapping to Libraries
Purpose of work directory in Tomcat
how we create a war file in j2ee