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

3.5k views Asked by At

I have a problem that, after a lot of reading and research, seems like tomcat is running another instance of itself and thus serving an old version of my updated app (or somehow has cached an older version of my webapp somewhere only serves that.) I work on the app in eclipse on a windows machine and deploy it on a Linux server as a ROOT app (Renaming the war file to a ROOT.war). What I'd like to know is if there's a way to locate the older version that tomcat is serving by getting tomcat to log an output of the context root of the servlet that's serving the older version of the app. As it stands it the moment any files created by the updated app get created in the right directory but because the app instances are different it can't access the files shortly after they're created. Any help/hints would be welcomed

1

There are 1 answers

4
BalusC On BEST ANSWER

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

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

To solve the problem described in the question, shutdown Tomcat and delete everything in its /work directory, delete the expanded WAR in /webapps and remove the /Catalina subdirectory of /conf directory (if any) and then restart.