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

Reading a File from a Java class deployed as a webservice on Jboss

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My webservice reads an xml file like this
BufferedReader in = new BufferedReader(new FileReader("myfile.txt"));
I have deployed the webservice as a jar in
$JBOSS_HOME\server\default\deploy\axis.war\WEB-INF\lib

The file myfile.txt is in the same jar. But I am getting a FileNotFoundException when I access the webservice.

What should I do?



Janis
 
Author
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Janis,
This is a similar problem to the one you're enountering when reading a properties file. First, look at my response to your post on "reading a properties file".

Using the ResourceUtil, do the following:

URL myFileUrl = ResourceUtil.getAsUrl("MyFile.txt");

InputStream is = myFileUrl.openStream();

Than, use the InputStream as you normally would.

Tom Marrs
Lead Author, JBoss at Work: A Practical Guide
 
Janis Lee
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. :-)
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic