• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File Not found Exception

 
B pandoo
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • 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.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • 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
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Hi,
I am using Tomcat Server.
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic