• Post Reply Bookmark Topic Watch Topic
  • New Topic

File not found problem  RSS feed

 
David Brossard
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I've recently developed a simple web service with Axis that makes use of a config file where I store values that I read from within one of my web service's classes.

The way I read the config file is as follows:

filename contains a relative path as suggested by the File API)

When I deploy my service to Tomcat, I ship the config file along with the jar that includes my classes that make use of the file and make sure the relative path between classes and the config file do match what I specified.

It's been working fine both when I test outside Tomcat and when I test within Tomcat but ever since yeterday I've had erratic behavior: sometimes it finds the file and more often than not, it fails to find it.

Could anyone please tell me what I'm doing wrong or better yet, how I should go about calling a config file from a class?

Thanks,
David.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a web application it's undefined what the default directory is. Try using absolute paths instead, e.g. ServletContext.getRealPath("/WEB-INF/my-config-file.txt").
 
David Brossard
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your tip. I got it working. For reference's sake, here's my code snippet that does it:

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!