This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

placing propertie file in .war file  RSS feed

 
suresh pulapally
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have created one properties file, in my application iam trying to read the properties file.i have placed the properties file in web-inf/ folder.
when i deploye the application,its giving me the FileNotFoundException.

could you please help where should i place the properties file,and how to read the properties file from java classes.
 
srikanth singamsetty
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
WEB-INF is the private folder in your tomcat..
you need to place the properties file in the classes folder ie
WEB-INF/classes/
 
srikanth singamsetty
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can read the properties file by the help of ResorseBuldle
which is existed in the java.util package
sample code to read the properties file
java.util.ResourceBundle resBundle = ResourceBundle.getBundle("PropertiesFilename");

/*
* please save the properties file with .propeties extension and place it in the WEB-INF/classes folder
*/
resBundle.getString("keyhere");
 
suresh pulapally
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I tried using ResourceBundle.i have placed .properties file in web-inf/classes folder, and the following code i have written to get property value.
java.util.ResourceBundle resBundle = ResourceBundle.getBundle("application.properties");
String jndi_name=resBundle.getString("jndiname");

its throwing following exception.
java.util.MissingResourceException: Can't find bundle for base name application.properties

Thanks
Suresh
 
David Ulicny
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try only application without properties extension
 
suresh pulapally
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,
Its working fine
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!