Without seeing an SSCCE and your project setup, this is just a guess, but I would do this:

getClass().getClassLoader().getResource(indexName);

Instead of this:
...