javagwttomcat

ClassLoader.getSystemResourceAsStream not working when running on tomcat


I am loading a configfile using ClassLoader.getSystemResourceAsStream. The file is placed in the src folder of my GWT application. It ends up in war/WEB-INF/classes. I copy the war folder to tomcat under webapps/MyApp. When running the application, getSystemResourceAsStream throws an exception. When running under Jetty it works fine.


Solution

  • Try:

    getClass().getClassLoader().getResourceAsStream();
    

    It will definitely work; I also had same type of problem. This question describes why you are having that problem.