• Post Reply Bookmark Topic Watch Topic
  • New Topic

Deploying WAR in Tomcat  RSS feed

 
vishwambhar bhat
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben Souther wrote:You don't need to extract them.
Tomcat will do it automatically.

Simply drop your war file in the tomcat/webapps directory and Tomcat will take care of the rest.



hey , I am finding some issue. when I deploy the war file directly to the webapp folder, the app works fine for few hours.  Later if I call the same link ,say after one day, i get [ ] response. And again if i upload the my war file in webapps, it works again. what could be the reason for this ?
 
Tim Holloway
Bartender
Posts: 18715
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Vishwambhar!

Officially, all webapps are WAR files, always.

However, many webapp servers - including Tomcat - support what is known as an "exploded WAR". An exploded WAR is simply a WAR file that has been unzipped.

Why explode a WAR? Actually, I have no idea. Presumably it's done to give some sort of performance advantage, although whether it does, and how much is unknown to me. Some people like to store data in their WAR (which they shouldn't do) and you cannot do that to a ZIPped-up WAR.

At any rate, the default behavior in the case of Tomcat, is that if you drop a WAR file in the TOMCAT_HOME/webapps directory, Tomcat will explode it into a subdirectory with the same name as the WAR file (minus the .war extension),

And this becomes the official WAR that will then automatically deploy and run.

The boldface emphasis is because once Tomcat explodes a WAR file, you have, 2 copies of the same webapp in the webapps directory, since Tomcat doesn't delete the original WAR. And, contrary to intuition, if you replace the WAR file with a newer version, Tomcat will not explode and re-deploy that newer WAR - it will continue to run the original exploded WAR unless you delete it (while Tomcat is shut down). That little quirk has confused and annoyed many people.

If a webapp stops running, that's probably a bug in the webapp. But if you update a webapp and it still runs old code, now you know why.



Incidentally, you can run webapps from other places than just TOMCAT_HOME/webapps, and you have the option as to whether the WAR file should explode or not. The webapps/auto-explode behavior is merely the default.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!