29

when I run my dynamic web project from eclipse it gets deployed to wtpwebapps. However I want to deploy a war file to tomcat so when I checked here in SO this came up How to deploy a war file in Tomcat 7

It says I have to deploy to webapps folder in tomcat.

Can anybody please explain me the details between wtpwebapps folder and webapps folder in tomcat and also if I can deploy war files to wtwebpapps folder instead of webapps folder.

Community
  • 1
  • 1
Nav
  • 10,304
  • 20
  • 56
  • 83

2 Answers2

43

wtpwebapps is an eclipse-specific folder created when you run a dynamic web project on Tomcat within eclipse.

Webapps directory is within the Tomcat home and it's where you copy over your WAR files manually.

asgs
  • 3,928
  • 6
  • 39
  • 54
  • 2
    so you mean to say that when I have to run my war file within eclipse I have to put them within wtpwebapps and when I have to deploy it in production(to the live server) then I will have to deploy it to the webapps folder. Am I correct in this ? – Nav Sep 16 '12 at 11:13
  • @Nav i'm not sure very sure about the first part where you talk about wtpwebapps, but Eclipse does this job of exploding the war inside wtpwebapps and creating the directory structure when the project is added to Tomcat server. – asgs Sep 16 '12 at 12:06
  • 1
    I am asking about real deployment to a live server. In that case which folder should I deploy to ? – Nav Sep 16 '12 at 12:46
  • @Nav In case of a real (production) deployment, Eclipse would be out of picture and there wtpwebapps directory is out of scope. The war file should go to $TOMCAT_HOME/webapps directory. – asgs Sep 16 '12 at 17:13
  • 6
    ok thanks ...one last question ...why does eclipse deploy the applications to wtpwebapps instead of webapps folder ...is there any specific reason to do so ??? – Nav Sep 16 '12 at 17:20
  • No idea, but I bet it's an Eclipse specific thing. Eclipse just mirrors your tomcat installation directory inside the ` – asgs Sep 16 '12 at 19:32
  • 5
    Actually, when you are in the Servers tab, if you double click the server you configured, the server config overview will open. In there, you'll find a section called "Server Locations", which allows to choose the location where Server should deploy the app. By default, it goes to `wtpwebapps`, where wtp is the Eclipse's web tools project. – asgs Dec 06 '13 at 19:40
0

Recently, i've struggled with webapp strange behavior while debugging in Eclipse. I've noticed that it was double deployed.

My setup was:

  • web module with context path that differs from document base;
  • enabled autoDeploy in server.xml;
  • and deploy was set into webapps directory.

When checking tomcat-manager i've noticed that this webapp was deployed once with its context path name and once with document base name.

Here is what the documentation states (All credits goes to octopus, Tomcat docs):

If you want to deploy a WAR file or a directory using a context path that is not related to the base file name then one of the following options must be used to prevent double-deployment:

Disable autoDeploy and deployOnStartup and define all Contexts in server.xml Locate the WAR and/or directory outside of the Host's appBase and use a context.xml file with a docBase attribute to define it.

And, i believe it's the main reason to use wtpwebapps instead of webapps for Tomcat with Eclipse.

diabolusss
  • 29
  • 1
  • 6