• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

reading .properties file

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
am reading a .properties from a standalone class which is used to load the application properties. project is deployed on WAS6.5 as EAR file. When i tried to load the file, it is looking from AppServer\profiles\default\ . My .properties file is in web-inf. Please let me where do i need to configure to read that property files.
 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If its trying to read there, then you must be doing a direct File IO (using the File API perhaps?) which is not permitted in J2EE or more specifically WebSphere, except in cases that files are on network drives.

There are multiple ways to read properties files (search javaranch, I've posted about this multiple times in this forum) but the best way I've found is getResourceAsStream() which loads files from the class path. Keep in mind though, that doing so means the application must be re-deployed if you want to change the properties file.
 
Nagaseshagiri poola
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your reply.
i used the file reading as mentioned getResourceAStream() but it is also throwing the same null pointer exception. i want to know how the config/properties files are read from the web-inf folder.
 
Scott Selikoff
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's possible you're not getting the right classloader or your class loader property isn't set right, see this recent post for more info: https://coderanch.com/t/77960/Websphere/Getting-nullpointerexception-while-getResourceAsStream
 
Morning came much too soon and it brought along a friend named Margarita Hangover, and a tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic