-
1. Re: Not able to read a file inside WEB-INF in jboss-as-7.1.0.Final
sfcoy Mar 19, 2012 9:20 AM (in response to aslamcl)Your file is not accessible from a classloader as it's not in the classpath (WEB-INF/classes/...).
You can it access using javax.servlet.ServletContext#getResourceAsStream(java.lang.String)
ie.
{code:java}servletContext.getResourceAsStream("WEB-INF/config/myfile.xml");{code}
-
2. Re: Not able to read a file inside WEB-INF in jboss-as-7.1.0.Final
aslamcl Mar 20, 2012 6:45 AM (in response to sfcoy)Thanks Stephen! It works.
I tried getServletContext().getResourceAsStream("
"/WEB-INF/config/myfile.xml
") and it works (Note:There is a leading slash '/' required beforeWEB-INF
).Just out of curiousity, shall I ask you one question,
getClass().getClassLoader().getResourceAsStream("..
/config/myfile.xml"
) - This was working in Jboss5.1GA but why not in AS7.1? -
3. Re: Not able to read a file inside WEB-INF in jboss-as-7.1.0.Final
sfcoy Mar 20, 2012 7:24 AM (in response to aslamcl)Aslam Mohd wrote:
Just out of curiousity, shall I ask you one question,
getClass().getClassLoader().getResourceAsStream("..
/config/myfile.xml"
) - This was working in Jboss5.1GA but why not in AS7.1?Given that JBoss classloading was once famously described as a "big ball of mud", I don't find this very surprising.
-
4. Re: Not able to read a file inside WEB-INF in jboss-as-7.1.0.Final
aslamcl Mar 20, 2012 8:10 AM (in response to sfcoy)Ok. Thanks stephen.
-
5. Re: Not able to read a file inside WEB-INF in jboss-as-7.1.0.Final
ramyamagham Apr 25, 2014 1:19 PM (in response to aslamcl)Leading slash worked for me, thank you!