• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

FileNotFound error while reading a properties file using relative path

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am moving my tomcat application to weblogic. I have successfully deployed the war file as it is to the weblogic server.

I get FileNotFound Exception when running this application from Weblogic server. The problem is caused while opening the filestream with the relative path WEB-INF/app.properties. My servlets are jar-ed.

I have tried several combination of specifying the path. none of the following are working :
/app/WEB-INF/app.properties
../WEB-INF/app.properties
./app/WEB-INF/app.properties

Someone, please tell me what I need to change for this to be working?

thanks.
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try setting up the classpath of app.properties file in the startWeblogic.cmd file. In this startWeblogic.cmd file look for ---

'set CLASSPATH'.

Hope this helps.
 
Ajay Reddy
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this does not work. Check where your code reads the property file location from.

I have created a directory called config. In this folder place your property file. This directory can be anywhere in your domain. But I have under bea8.1/user_projects/domain_name/config.

In your code when you like to lookup keys, read the values of the key.

String filePath = f.getAbsolutePath() + File.separator + "config" + File.separator + "application.properties";


FileReader read = new FileReader(new File(filename));
BufferedReader bRead = new BufferedReader(read);
String line = "";
boolean found = false;

while(((line = bRead.readLine()) != null) && (!found)) {
if (line.length() > newKey.length() + 1) {
if (((line.substring(0,newKey.length() + 1)).toUpperCase()).equals (newKey + "=")) {
s = line.substring(newKey.length()+1);
found = true;
}
}
}
read.close();

where newKey is key that you want to lookup the value.

KEY VALUE
---------------
SERVER=127.0.0.1

So the key is SERVER and the corresponding value=127.0.0.1

Hope this helps.
 
Ranch Hand
Posts: 51
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just change ur ntry in web.xml

put path /web-inf/....

hope this will solve ur problem
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't tested this, but see if it works (to find the file app.properties and load it into a Properties object).
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!