You can get root path of application from ServletContext.
If you have relative path of file, you can get it's real path using servletContext.getRealPath().
eg:
String realPath = servletContext.getRealPath("/data/files/myfile.xml");
You can also get root path of your application using servletContext.getContextPath(). Root path can then be used to refer to your file. eg:
String rootPath = servletContext.getContextPath();
String filePath = rootPath + "/data/files/myfile.xml";
In case servletContext is not accessible to you in your class, you can store root path of your application in init-param or properties, and can use it.