Search code examples
springtomcatjenkinstomcat8

Tomcat mapping URLs wrong


I edited context path in TomCat server.xml, so that my webapps/app is displayed as root app instead of TomCat app on mysite.com (not mysite.com/app). In my app i have some .jsp files that are displayed correctly (mysite.com/main, /register) but some sites give me 404 error (mysite.com/home, /rxmsg, /signout). Yet when i go to mysite.com/app/home, everything works perfectly

Every URL like this works perfectly in local (localhost:8080/home)

My git pushes are transfered to tomcat_home/webapps/ via jenkins

What causes some urls to 404?

Redirects are made by

return "redirect:main"; //URL is changing

or

return "main"; //URL not changing

Solution

  • I managed to find the problem In my tomcat server.xml changed

    <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
    

    to

    <Host name="mysite.com"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
    

    and restarted my service.

    BUT doing so, I cannot test my code on localhost now.