I read about this on Tomcat guide here and some SO questions. And I think I'm pretty much doing the same thing. But in some way cannot manage to succeed.
First of all I have to say that my application is deployed on a shared Tomcat server that I have no control over. I just drop my .war file and it gets deployed.
I tried to package my application as ROOT.war but didn't work. The admin told me to package it as whatever the name I want and they would take care of it. I packaged it as my-application.war and it got deployed but I have to enter http://my-host/my-application to get to the website.
After contacting the admin they told me that they have put a context elemnt in my host in Tomcat config file like:
<Context path="" docBase="path of my-application deployed folder"/>
which was supposed to set my-application as default application for all the requests coming to my-host
. But it didn't and whenever I enter http://my-host I get:
HTTP Status 404 - / The requested resource (/) is not available
But again when I enter http://my-host/my-application it all works fine. Any suggestion on what might be wrong is definitely appreciated.
Updates:
I tried to follow the steps described in tomcat documentation on how to make the application default. 3 ways are described and I tried all three ways and could successfully deploy my application as ROOT on localhost.
I also tried to reproduce the problem I'm facing on remote server so I could find the reason and report it to admin. I find couple of problems.
Either way I couldn't exactly pinpoint what exactly is preventing ROOT.war from deploying since that requires the access to Tomcat log files and conf files to check the cases I described above.
Also from all I see my the admin seems incapable of maintaining a Tomcat server and finding the problem. So I decided to go with a dedicated Tomcat server after struggling with the shared one.
The context path refers to the location relative to the server's address which represents the name of the web application. By default, Tomcat derives it from the name of the deployed war-file. So if we deploy a file ExampleApp. war, it will be available at http://localhost:8080/ExampleApp.
if you use same console for both apps - you can deploy application on different servers (different ports) with same context root, but you must use different application name.
In your question, you state that the admin set the context as:
<Context path="" docBase="path of my-application deployed folder"/>
Based on the comments above, I would suggest trying to use the relative path of your application rather than the absolute path.
I tried this on my tomcat server with:
<Context path="/" docBase="my-application/" />
and that did the trick.
The Host element which contains the Context element does actually set some parameters that might also impact the context. If it's the default settings, then a relative context should simply point to the webapps folder. If it's been changed, the results may vary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With