Reputation: 97
I have Spring Tool Suite (3.9.2.RELEASE) which by default comes with the Pivotal TC web server, a variant on Apache Tomcat. From what I understand, in order to set the "default website" for Tomcat you modify the 'context' which points to your application. Best practices may say to define this in a different file, however I understand it is still possible to be done in 'server.xml'.
I have an application ("myApp") in STS. It is normally accessed via http://localhost:8080/myApp
. I would like to access it at http://localhost:8080
instead.
The following is a snip from the Pivotal TC 'server.xml'
<Context docBase="myApp" path="/myApp" ... />
I have modified this as follows, however I still reach the default Pivotal tc Server Runtime home page instead of my own:
<Context docBase="" path="/myApp" ... />
Is there another location where I should be applying these changes to make them effective? There is obviously a something that I do not understand.
Many thanks in advance for your input.
Upvotes: 0
Views: 267
Reputation: 48067
Looking up tomcat's documentation for both attributes that you mention in your Context element, you'll find out:
docBase:
The Document Base (also known as the Context Root) directory for this web application, or the pathname to the web application archive file (if this web application is being executed directly from the WAR file). You may specify an absolute pathname for this directory or WAR file, or a pathname that is relative to the appBase directory of the owning Host.
The value of this field must not be set unless the Context element is defined in server.xml or the docBase is not located under the Host's appBase...
path
The context path of this web application, which is matched against the beginning of each request URI to select the appropriate web application for processing. All of the context paths within a particular Host must be unique. If you specify a context path of an empty string (""), you are defining the default web application for this Host, which will process all requests not assigned to other Contexts.
This attribute must only be used when statically defining a Context in server.xml. In all other circumstances, the path will be inferred from the filenames used for either the .xml context file or the docBase.
Even when statically defining a Context in server.xml, this attribute must not be set unless either the docBase is not located under the Host's appBase or both deployOnStartup and autoDeploy are false. If this rule is not followed, double deployment is likely to result.
In other words: You should modify the path
attribute. When you do this, make sure to also undeploy the default content that would otherwise conflict with your own definition.
You'll also figure out that ""
is not a valid docBase, as it specifies a WAR file or a directory.
Upvotes: 1