Thursday, August 10, 2006

Changing or renaming the ROOT folder in Tomcat

1.
Look for this...
<Context path="" docBase="ROOT" />
and change it to
<Context path="" docBase="NEW_FOLDER_NAME" >

If it is not there as default. Then it needs to be added inside the <host> tag. (which is inside the <engine> tag)


2. Stop tomcat

3. Delete the files in

work\Catalina\localhost

4. Start tomcat



10 comments:

  1. Hello... i have a small problem here, and tho this aint exactly a tech mailing list or forum, i thought u may be able to help...

    well, i want my webapp to be at "/" and i want ROOT to be at, say "/orig/" ... what shud i do in this case? i changed folder names... i renamed my webapp to "ROOT" and also "ROOT" to "orig". However, the Tomcat Manager doesnt work anymore.

    ReplyDelete
  2. hi swapz

    inside your <host> tag in server.xml you might want to try adding:

    <Context path="/manager" debug="0" privileged="true" docBase="${catalina.home}/server/webapps/manager">
    <ResourceLink name="users" global="UserDatabase" type="org.apache.catalina.UserDatabase"/>
    </Context>


    let me know if that works. cheers!

    ReplyDelete
  3. MARK!!!!!!!!!!!!!!!!

    I lOVE YOU AS A DEVELOPER !!!!!!!

    Thank you so much !!! God Bless you.. and I mean it

    Best Regards

    Errol ;)

    ReplyDelete
  4. You have mentioned
    "1.
    Look for this...
    Context path="" docBase="ROOT"
    and change it to
    Context path="" docBase="NEW_FOLDER_NAME" "

    But where do I look for? In which file, in which folder?

    ReplyDelete
  5. good point staraphd. it should be in the 'server.xml' in your tomcat's 'conf' folder.

    although this location will be different depending on your installation and operating system. for example, the server.xml in my windows installation is located at: "C:\Program Files\Apache Software Foundation\Tomcat 6.0\conf"

    ReplyDelete
  6. Ok got it. I have same folder structure as yours.

    Further questions
    1. Does context tag need a closing tag
    For example do I do this...
    <Context path="" docBase="NEW_FOLDER_NAME" >
    </Context>

    OR

    <Context path="" docBase="NEW_FOLDER_NAME" />

    2. Is docBase="" just the folder name or the complete path? If path, is it the relative path or the absolute path?

    3. Can I place the "NEW_FOLDER" anywhere in C: or D: or are there any restrictions?

    ReplyDelete
  7. Hmm.. I'm trying to remember as it was a long time ago when I last did this. To answer your questions:


    1. context needs closing tag in the tag itself. i.e. <Context path="" docBase="NEW_FOLDER_NAME"/>

    2. Something I missed out about this post was the "host" tag which your "context" tag should be nested inside. For example:

    <Host name="www.theintelligentcrowd.com" appBase="d:\website\webapps\" >

    therefore:

    "appBase" will be the base of your application.

    "path" in your context tag will be the path from your appBase

    All in all, it might look like this:

    <Host name="www.theintelligentcrowd.com" appBase="d:\website\webapps\">
    <Context path="" docBase="theintelligentcrowd" />
    <Context path="/theintelligentcrowd" docBase="theintelligentcrowd" />
    </Host>


    3. No restrictions. See my appBase as in #2.


    Other notes: This is Tomcat 5.5, on Windows Server 2003, but I think newer versions work the same.

    ReplyDelete
  8. Thanks Mark.

    I tried your suggestions.
    It works provided I do not change HOST name="localhost"

    If I change to HOST name="www.mywebpage.com" or anything else its not able to load

    ReplyDelete
  9. just remove the ROOT dir and make a symlink. Open console in catalina home and : >sudo rm -rf ROOT; then >sudo ln -s YourAppDir ROOT;

    ReplyDelete
  10. staraphd: you'd need your server to be actively hosting the website "www.mywebpage.com" for it to work like that. for the meantime "localhost" should do just fine :)

    buri: thanks! my original post was for windows (which didn't used to support symbolic links). using symlinks is a great idea.

    ReplyDelete