• Post Reply Bookmark Topic Watch Topic
  • New Topic

Tomcat 8 webapp redirects to Default ROOT webapp  RSS feed

 
Libu das
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



I have a tomcat8 app server with three applications webapps/ROOT(URL : https//one.example.com) webapps/test ((URL : https//one.example.com/test) and webapps/manager(URL : https//one.example.com/manager). The issue is when i am trying to deploy a new build to test and the application is down but the URL https//one.example.com/test redirects to https//one.example.com.Is there a way to stop this automatic redirection to another webapp

Note : https//one.example.com/ is the Live application and https//one.example.com/test is the test application

Thanks in advance
 
Tim Holloway
Saloon Keeper
Posts: 18799
74
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Libu!

If I understand you correctly, you're annoyed that when the test application is not running, a URL of http(s)://one.example.com/test (or something similar) is being routed to the root webapp.

Sorry, but that's how just about any webapp server will do things. When a URL request comes in, it is pattern-matched against the context paths of all webapps deployed for that host. Whichever one matches best then receives the request, where the URL is further parsed to determine what resource (servlet, jsp or file/directory) should be used to resolve it. When the "test" application is not deployed (stopped), that makes the "/" context path be the closest match. In the even, there's no resource named "test" in the root webapp, then you should get a Tomcat 404 Not Found error page returned.

If that's unacceptable, about the only thing you can do is modify the root webapp. You could add a servlet that returns a page saying something like "Sorry, application "test" is not available right now" and map it to the resource URL path "/test" in the root webapp's WEB-INF/web.xml, for example.
 
Libu das
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim
Thanks for your reply , The issue i am having is i can't remove or modify webapps/ROOT application as this serves as the Live app. So when ever test is stopped access to test URL will be redirected to Live serving the webapps/ROOT application.
I am quite happy to get a 404 or any error page when test is down .

Is there way to do this without altering  webapps/ROOT ?


Thanks in advance
Lib
 
Paul Clapham
Sheriff
Posts: 22832
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One way would be to not have the Live app be the root application. If the application context for the Test app is "test" then make the application context for the Live app be "live" -- or something like that.
 
Tim Holloway
Saloon Keeper
Posts: 18799
74
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, it's really not good practice to mix test and production apps in a single server. Consider running a separate Tomcat instance for the test app.

My usual shop standard goes something like this:

1. Local testing and development (copy of Tomcat on my local machine)
2. Beta/QA testing (your "test" app) on a test server
3. Production on a production server.

I also inject application configuration information via JNDI so that the exact same WAR works on all 3 environments - no having to build a new WAR to change from using the Beta database to using the production database.
 
Libu das
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim and Paul

I think i will go with Virtual hosting or a separate tomcat instance for test

Best Regards
Lib
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!