This is working correctly locally, but not when hosting on AWS. I've been attempting to debug this for a week and can't seem to crack it.
Here is the code block that I believe is causing my issue. In short, I'm attempting to find the "resources" directory inside my project that is holding some .jmx files (JMeter tests), and put them into a list. The "slash" variable is holding System.getProperty("file.separator").
Stream<Path> walk = Files.walk(Paths.get(System.getProperty("user.dir") + slash + "src" + slash + "main" + slash + "resources"), 1)) {
result = walk.map(x -> x.toString())
.filter(f -> f.endsWith(".jmx") )
.collect(Collectors.toList());
When running locally, the directory is: C:\Users\user.name\repos\my-project\src\main\resources
When running on AWS it looks like the directory is: /usr/share/apache-tomcat-8.5.30/src/main/resources
Here is the error I'm getting after deploying to an AWS instance:
java.nio.file.NoSuchFileException: /usr/share/apache-tomcat-8.5.30/src/main/resources
Am I missing something with how System.getProperty("user.dir") would work when hosted on AWS? My thought is that looking for a specific directory instead of just getting "user.dir" is causing some issue, but I'm not sure.
So far I've tried:
- Making sure there aren't any access issues with AWS
- Adding and removing the trailing slash at the end of the directory path
- Removing the + slash + "src" + slash + "main" + slash + "resources" so it's just grabbing "user.dir", which seems to work, but I need to be able to get more specific with the folder location.