Issue
I run 2 tomcat instances on two different servers. I deploy the same war file on both of them but it doesn't work the same way.
On instnace one everything is fine while on instance two I get a NullPointerException because the variable "resource" in the "listAllConfigIds" method is NULL.
public List<String> listAllConfigIds() {
URL resource = SomeClass.class.getResource("./");
LOG.debug("Loading from resource " + resource);
return Arrays.asList(new File(resource.getPath()).list()).stream().filter(s -> !s.toLowerCase().contains("."))
.collect(Collectors.toList());
}
I started tomcat with the same vm args on AIX. Any ideas what the problem coud be?
Solution
Instead of the relative path I am now building the absolute path:
SomeClass.class.getName().substring(0, SomeClass.class.getName().lastIndexOf(".")).replace(".", "/");
Strip the last part and replace "." with "/"
Answered By - ave4496