I need to load a file resource when starting my server. So I placed the file under webapp/WEB-INF.
The problem is that the unit tests fail.
I try to load the file using:
URL url = Utils.class.getClassLoader().getResource(fileName);
File file = new File(url.getFile());
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
But the class loader does not find the file. It seems like it is looking for it at
file:/C:/<local path>/<my project>/target/test-classes/
- There are different contexts for during normal mode and test mode
I tried also the solution suggested here but it didnt work