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

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: 4342
40
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: 4342
40
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
 
Those are the largest trousers in the world! Especially when next to this ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic