aspose file tools*
The moose likes Websphere and the fly likes reading .properties file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "reading .properties file" Watch "reading .properties file" New topic
Author

reading .properties file

Nagaseshagiri poola
Greenhorn

Joined: Oct 18, 2003
Posts: 25
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.
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3716
    
    5

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.


My Blog: Down Home Country Coding with Scott Selikoff
Nagaseshagiri poola
Greenhorn

Joined: Oct 18, 2003
Posts: 25
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
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3716
    
    5

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: http://www.coderanch.com/t/77960/Websphere/Getting-nullpointerexception-while-getResourceAsStream
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: reading .properties file