| Author |
File Not found Exception
|
B pandoo
Ranch Hand
Joined: Nov 14, 2006
Posts: 37
|
|
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
Joined: Mar 22, 2000
Posts: 12269
|
|
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
|
Java Resources at www.wbrogden.com
|
 |
Peer Reynders
Bartender
Joined: Aug 19, 2005
Posts: 2906
|
|
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.
|
"Don't succumb to the false authority of a tool or model. There is no substitute for thinking."
Andy Hunt, Pragmatic Thinking & Learning: Refactor Your Wetware p.41
|
 |
B pandoo
Ranch Hand
Joined: Nov 14, 2006
Posts: 37
|
|
Hi, I am using Tomcat Server.
|
 |
Peer Reynders
Bartender
Joined: Aug 19, 2005
Posts: 2906
|
|
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
Joined: Nov 14, 2006
Posts: 37
|
|
Hi, i am using Axis1.x.Is there any possibility that the property file can be read without getting the ServletContext.
|
 |
 |
|
|
subject: File Not found Exception
|
|
|