• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Cannot Find "Properties" File

 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a MessageResources.properties file that contains the text to be displayed on the labels and buttons in the form.
Nonetheless, I got HTTP Status 500 and the problem is that the text provided in that file cannot be picked up - I think it results from not finding the file.
I checked:
1. name of the file: it is a correct spelling
2. location of the file: it is in the correct directory
3. type of the file: the Windows Explorer shows the type of that file is a PROPERTIES file
I need your experience to tell what else could go wrong. Please help.
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jen,
Are you trying to load the properties file thru a servlet? If so the problem could be that the servlet can't see a file on the host's file system. All it is going to be able to see are files in its virtual path.
Michael Morris
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The properties file is kept in the same directory with all compiled servlet class files.
I am very frustrated by the problem.
 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[mods: plz move this thread to Servlets forum]
I was totally frustrated with this for a while. I got intermittent behavior and figured out that when I start Tomcat from the directory containing .properties file, it worked. I think it has to do with the classloader finding it in that case.
Fortunately, there's a much better solution than that.
You must use Class.getResourceAsStream() so that tomcat can find the file.
Here's an example:
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic