• 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

File Not found Exception

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am new to Webservice concepts.I had a client and server side application.There is a property file in Serverside.I am trying to read the data from property file using the following code
Properties props = new Properties();
try {
props.load(new FileInputStream("StatementType.properties"));
statementType = props.getProperty("statementdefintionName");
}
catch(IOException e){e.printStackTrace();}
I have placed the property file under WebContent folder.

While making a call from Client side and invoke the webservice,it is throwing a FileNotfound exception as it is unable to locate the file.Please let me know why during a webservice call,it is unable to locate a file in server side.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


That code depends on the "current" directory - something you have no control over in typical servers. You will need to find a way to get the absolute path to the properties file. What server are you using?

Bill
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These might help you out.
javax.servlet.ServletContext.getRealPath
javax.servlet.ServletContext.getResource
javax.servlet.ServletContext.getResourceAsStream

You can get the ServletContext from
javax.xml.rpc.server.ServletEndpointContext.getServletContext
if the web service is a JAX-RPC servlet.

You obtain the ServletEndpointContext in an JAX-RPC servlet by implementing the
javax.xml.rpc.server.ServiceLifecycle - the ServletEndpointContext is passed through the init method.

So basically you have to find a way of obtaining the your ServletContext.
 
B pandoo
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am using Tomcat Server.
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by B pandoo:
Hi,
I am using Tomcat Server.



With what SOAP stack? Axis 1.x, Axis 2, JWSDP 1.x ....
 
B pandoo
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
i am using Axis1.x.Is there any possibility that the property file can be read without getting the ServletContext.
reply
    Bookmark Topic Watch Topic
  • New Topic