• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

reading .properties file

 
Nagaseshagiri poola
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • 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.
 
Scott Selikoff
author
Saloon Keeper
Posts: 4014
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • 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
  • 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
Saloon Keeper
Posts: 4014
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • 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: http://www.coderanch.com/t/77960/Websphere/Getting-nullpointerexception-while-getResourceAsStream
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic