3

I have a Tomcat6 server on a Linux server. The structure of the webapps directory is:

  • examples
  • host-manager
  • manager
  • ROOT
  • sample

I have a web application running on my localhost on a Tomcat. I created a war file MyProject.war and put it into the webapps directory. Restarting the Tomcat server, the war is extracted and I have this structure:

  • examples
  • host-manager
  • manager
  • MyProject
  • ROOT
  • sample

Calling the URL http://mysubdomain.mysite.com:8080/ I get the Tomcat start page with

If you're seeing this page with a web browser, it means you've setup Tomcat successfully. Congratulations!.

Calling http://mysubdomain.mysite.com:8080/MyProject/ I get the page of my project.

What I want, is that I can access my project with the URL http://mysubdomain.mysite.com:8080/ and not with http://mysubdomain.mysite.com:8080/MyProject/

How can I do this?

Best Regards.

Update I have this in my server.xml:

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

I did it on path with an empty string and / and restart Tomcat. Both does not work. The main directory shows me the Tomcat start page instead of my project. The project is only reachable with ...:8080/MyProject/

1 Answer 1

4

Delete ROOT folder, rename MyProject.war to ROOT.war and restart.

You can also do it by adding the following line to inside the <Host> entry of /conf/server.xml

<Context docBase="MyProject" path="" />
8
  • Thank you for your reply. Where can I write/change the docBase attribute of the Context element on my server?
    – Tim
    Jan 16, 2011 at 19:52
  • Click the link behind <Context> in my answer for possible locations. I personally suggest /META-INF/context.xml file inside the webapp in question.
    – BalusC
    Jan 16, 2011 at 19:56
  • I searched, but inside my project, there is no context.xml. In META-INF there is only a MANIFEST.MF
    – Tim
    Jan 16, 2011 at 20:04
  • Sorry, I have to take it back. For a webapp which is to be deployed as ROOT, you can't declare it like that in context.xml (otherwise, you just create one yourself).
    – BalusC
    Jan 16, 2011 at 20:55
  • I add the line with Context to the server.xml and restart the Tomcat server (I updated my question). So this solution does not work or I did something wrong?
    – Tim
    Jan 17, 2011 at 9:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.