I am having trouble understanding how the ResourceLoader locates resources. When I deploy the code on the server it runs fine but it fails in my eclipse test environment when running integration tests. My project is laid out as a typical maven webapp with separate src and test code trees.
I can make the tests work if I hard code the resource location with the full path but it destroys portability.
//This works fine when deployed but fails during tests
Resource file = resourceLoader.getResource("/WEB-INF/reports/report1.jasper");
I tried the following (and a few other variations) after reading the reference a little more closely but it doesn't seem to work either.
//HARD CODED: This works fine in tests but fails in deployed
Resource file = resourceLoader.getResource("file:/eclipse_work/myApp/src/main/webapp/WEB-INF/reports/report1.jasper");
Any idea what I might be missing?
Resource file = resourceLoader.getResource("classpath*:WEB-INF/reports/report1.jasper");