[jboss-user] [Beginners Corner] - Reading properties file
iamsonali
do-not-reply at jboss.com
Thu Nov 30 10:33:00 EST 2006
Hi,
I have an MBean, which along with other files is deployed as a .sar file in my application. I need to setup a properties file which will be read from this MBean file. I created a custom.properties file and placed it in META-INF.
To read it, I tried the following commands:
1) this.getClass().getClassLoader().getResource("custom.properties")
2) ClassLoader.getSystemClassLoader().getResource("/META-INF/custom.properties")
3) File props = new File("/META-INF/custom.properties");
None of these seem to work, I get null in return.
I do not have to place the file in META-INF, but I did this for my web application and read it in a servlet using -
file = "/META-INF/custom.properties";
config.getServletContext().getResourceAsStream(file);
and it worked.
I think the problem is that my java class cannot read the file from within the .sar file.
Does anyone have any suggestions? Thanks in advance.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3990112#3990112
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3990112
More information about the jboss-user
mailing list