Published 19 Sep, 2022

Java - Deploying my application at the root in Tomcat

Category Java
Modified : Oct 03, 2022
22

I have the war file of my application. I need to deploy this at the root level. The current URL is http://localhost:8080/war_name/application_name.

Answers

There are 4 suggested solutions here and each one has been listed below with a detailed description. The following topics have been covered briefly such as Java, Tomcat. These have been categorized in sections for a clear and precise explanation.

250

You have a couple of options:

  1. Remove the out-of-the-box ROOT/ directory from tomcat and rename your war file to ROOT.war before deploying it.

  2. Deploy your war as (from your example) war_name.war and configure the context root in conf/server.xml to use your war file :

    <Context path="" docBase="war_name" debug="0" reloadable="true"></Context>
    

The first one is easier, but a little more kludgy. The second one is probably the more elegant way to do it.


74

on tomcat v.7 (vanilla installation)

in your conf/server.xml add the following bit towards the end of the file, just before the </Host> closing tag:

<Context path="" docBase="app_name">
    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>

Note that docBase attribute. It's the important bit. You either make sure you've deployed app_name before you change your root web app, or just copy your unpacked webapp (app_name) into your tomcat's webapps folder. Startup, visit root, see your app_name there!


49

open tomact manager url :- http://localhost:8080/manager/html/
then in applications you see a application having path as "/" is deployed
simply Undeploy this.
enter image description here Rename your application's war file as ROOT.war and just place at path :-
C:\Program Files\Apache Software Foundation\Tomcat 8.5\webapps
start your Tomcat No extra configuration needed.
Now we can see our application home page or configured url at http://localhost:8080


40

Adding on to @Rob Hruska's sol, this setting in server.xml inside section works:

<Context path="" docBase="gateway" reloadable="true" override="true"> </Context>

Note: override="true" might be required in some cases.