Apache Tomcat under Windows: Changing webapps default directory

56,551

Solution 1

I have very the same security issue with Vista and I resolve it by providing "Full control" access level for "Users" group on "Program Files\Apache Software Foundation\Tomcat XYZ" folder.

It resolved deployment issues with tomcat for me as well as question on starting tomcat as a service. Of course you can assign permissions more strictly (per deployment user group or per user). IMO it's more quicker way then reconfigure the tomcat.

Regarding your original question how to change path outside of ${catalina.home} under Windows:

It's very the same as you have to accomplish it on *nix:

  <Host name="localhost"  appBase="/c:/webapps2"
        unpackWARs="true" autoDeploy="true"
        xmlValidation="false" xmlNamespaceAware="false">

Did you have ROOT folder in you folder mentioned in appBase? The approach is tested under Tomcat 6.0

Solution 2

The following should work in Windows:

C:/Users/maerch/Workspaces/Tomcat6.0_webapps/
/Users/maerch/Workspaces/Tomcat6.0_webapps/

Windows also support Unix's slash (/), so it's a good idea to use this instead of Windows's (\). Also the 'default root' for Windows is C:, so you shouldn't need it in an absolute path.

I don't think this is a problem with the path. Perhaps you could try use a relative path:

"../../../Users/..."

It may also be good idea to install Tomcat in a directory where you have full access.

Solution 3

What if you copy the same webapps directory to another location and change the path in server.xml file. If we would do this then definitely i believe we won't have any probs because whenever things webapps need to deploy an application it will have.

Share:
56,551
maerch
Author by

maerch

Updated on May 18, 2021

Comments

  • maerch
    maerch almost 3 years

    I am deploying my Java application with Ant. Unfortunately my test deployment on the local machine doesn't work because of Vista. The Program Files directionaries are protected and i don't want to start Ant or Eclipse as an Admin. So i had the idea to move my webapps folder to a workspace subfolder, so i can use relative paths in Ant as well.

    The solutions seems to be to modify the Host element in the server.xml. With Linux it isn't such a deal:

      <Host name="localhost"  appBase="/path/to/webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
    

    But with Windows i don't get it right. I tried every possible combinations i could imagine, like:

          C://Users//maerch//Workspaces//Tomcat6.0_webapps
          C:/Users/maerch/Workspaces/Tomcat6.0_webapps
          C:\Users\maerch\Workspaces\Tomcat6.0_webapps
          C:\\Users\\maerch\\Workspaces\\Tomcat6.0_webapps
          C://Users//maerch//Workspaces//Tomcat6.0_webapps\\
          C:/Users/maerch/Workspaces/Tomcat6.0_webapps/
          C:\Users\maerch\Workspaces\Tomcat6.0_webapps\
          C:\\Users\\maerch\\Workspaces\\Tomcat6.0_webapps\\
    

    The path is also correct, but it doesn't work. There are also no error messages in the log files neither the browser shows a 404 message or anything else. Just a white page without title and so on. Can anyone help?

  • maerch
    maerch about 15 years
    You are right. I don't know why i didn't think about this. Solves my problem, but unfortunately its not an answer for the questions, so you get only your reputations up! ;-) I am still interested in solving this. Found a lot of websites which haven't a clue.
  • Michael Schmidt
    Michael Schmidt about 15 years
    Regarding space in file/folder names: I'm completely agree with Vinegar, but it's not point of view Microsoft anymore. For a long time default directory for 3-rd party software is "Program Files" or "Program Files (x86)".
  • Shailesh
    Shailesh about 7 years
    I have changed the server.xml as per the given <host> but tomcat doesn't starts..! what other needs to be changed ? (On Ubuntu system)