After long hours at night I found the solution. Thanks to everybody for helping out.
I replaced my DomParser class code as below
import org.jdom2.input.SAXBuilder;
import org.jdom2.Document;
public class DOMParser {
static SAXBuilder builder = new SAXBuilder();
static Document doc;
...
...
public static void loadXML(String path) {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
java.net.URL url = classLoader.getResource(path);
doc = builder.build(url);
root = doc.getRootElement();
}
So, the key trick was to use the following code line.
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
This allows you to run your application as following ways
- Eclipse > Run as java application
- maven exec plugin
- executable jar with maven shade plug in
I hope this help other people have similar issue in future.
UPDATE:
I forgot to mention that I also slightly modified the App class code. Just one line. I pass file anme without forward slash as below.
DOMParser.loadXML("config.xml");