5

I am having a trouble getting my web application 'xyz' running in tomcat 7 server hosted in DigitalOcean servers at:

http://myDomain:8080/myWebApp

The name of my .war file is ".MyWebApp".

after deploying the .war file in tomcat, the application starts at:

http://myDomain:8080/MyWebApp/myWebApp

any idea how to remove this "MyWebApp" part from the URL?

I have seen some of the solutions for this problem, they are mostly solutions of running the application in localhost. They suggested to change the 'context.xml' file which I already did like this:

<?xml version='1.0' encoding='utf-8'?>
<Context>

    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>

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

Any help would be very much appreciated!

Do not mark this as duplicate. I have checked all the solutions which worked for me in localhost, but not in digital ocean VPS. I think I am pretty specific here.

Thank you in advance!

Tanvir Hossain Khan
  • 537
  • 1
  • 7
  • 22

2 Answers2

3

I had to add this line in in the server.xml file. Tod do this:

nano etc/tomcat/server.xml

add this line:

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

Save the file.

Restart tomcat.

Tanvir Hossain Khan
  • 537
  • 1
  • 7
  • 22
1

The simplest way is to rename your app to ROOT.war

Not very elegant, but pretty much foolproof.

There are of course other solutions.

Community
  • 1
  • 1
Malt
  • 28,965
  • 9
  • 65
  • 105
  • Yeah, renaming the war file to ROOT is not elegant, and may create troubles if I have more than one web app. I have checked out your link. These three methods are basically solutions to set the default application. But in the case of multiple web apps running in my tomcat server how can I skip the war file name to access the app that is the problem where I am stuck basically. – Tanvir Hossain Khan Feb 02 '15 at 00:14
  • I tried the second method adding this line just before the ending tag of in my server.xml: `` It percially solved the problem as I can access it skipping the war file name. But the probleam is it is also running another different instance with the war file name. It's surely a performance degrade! – Tanvir Hossain Khan Feb 02 '15 at 01:49
  • @TanvirHKShuvo that's why I prefer the ROOT.war solution. This question has been asked several times, and the solutions are always the same: http://stackoverflow.com/questions/7276989/howto-set-the-context-path-of-a-web-application-in-tomcat-7-0 – Malt Feb 02 '15 at 08:40