dcsimg
JUnit and getContextClassLoader() in Tomcat
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Tuesday, December 29, 2009 09:21 AM

Hi, I've a tomcat webapplication with some classes (no servlets), with code like this: InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("../" + filename); Properties props=new Properties(); props.load(is); With this code i can read property files in WEB-INFfilename. I want to test these classes with junit, but if i call classes with the code you can see above, i get an nullpointer exception, because the file can't be found. Is there a possibilty to solve this problem without changing the code in my classes? regards reini    More>>

Hi,



I've a tomcat webapplication with some classes (no servlets), with code like this:



InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("../" + filename);

Properties props=new Properties();

props.load(is);




With this code i can read property files in WEB-INFfilename.






I want to test these classes with junit, but if i call classes with the code you can see above, i get an nullpointer exception, because the file can't be found.



Is there a possibilty to solve this problem without changing the code in my classes?



regards

reini

   <<Less
About | Sitemap | Contact