Is there a way to get the absolute context root path in tomcat?

I have a problem that after many readings and studies it seems that tomcat starts another instance on its own and thus serves the old version of my updated application (or somehow cached the older version of my webapp somewhere only serves that. ) I am working on an application in eclipse on a Windows machine and deploying it on a Linux server as a ROOT application (renaming the war file to ROOT.war). I would like to know if there is a way to find the older version that tomcat is serving by forcing tomcat to log the output of the context root of the servlet serving the older version of the application. Since it stands at the moment when all the files created by the updated application are created in the correct directory, but since the application instances are different, it cannot access the files soon after they are created.Any hints / tips would be appreciated

+3
source share
1 answer

To answer the question in the title, let your code basically do the following:

System.out.println(getServletContext().getRealPath("/"));

As described in the question to resolve the problem, close the Tomcat and delete everything in its directory /work, delete the expanded WAR in /webappsand remove the subdirectory /Catalinadirectory /conf(if any), and then restart.

+3
source

Source: https://habr.com/ru/post/1794322/


All Articles