-
1. Re: jboss appending jndi:/localhost/ before the resource path
jaikiran Apr 15, 2010 1:56 PM (in response to anithakothandapani)Please post the entire exception stacktrace. And is that the exact piece of code in your app? If not, please post the relevant snippet.
-
2. Re: jboss appending jndi:/localhost/ before the resource path
anithakothandapani Apr 16, 2010 1:42 AM (in response to jaikiran)
HiThanks for the reply.
This is the complete snippet which I am using
URL url = servletContext.getResource("WEB-INF/conf")
String confLocation = url.getPath();
InputStream is = new FileInputStream(confLocation+"/myConfig.xml");Here I am getting the FileNotFoundException ,
Since the path is appended with localhost like this "/localhost/SampleWebApp/WEB-INF/conf/myConfig.xml"
myConfig.xml is the xml file which I want to use and it exists in the WEB-INF/conf location. /SampleWebApp is the context root of my web application
I am not sure how to prevent appending localhost before the path.
kindly help me on this regard.
-
3. Re: jboss appending jndi:/localhost/ before the resource path
jaikiran Apr 16, 2010 12:13 PM (in response to anithakothandapani)Anitha Kothandapani wrote:
InputStream is = new FileInputStream(confLocation+"/myConfig.xml");Here I am getting the FileNotFoundException ,
Don't use FileInputStream in a server environment. Instead use :
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("WEB-INF/conf/myConfig.xml");
-
4. Re: jboss appending jndi:/localhost/ before the resource path
anithakothandapani Apr 17, 2010 5:33 AM (in response to jaikiran)Thanks jaikiran. I tried your snippet, it worked.