I have deployed a webservice in apache-tomcat-5.5.23 using Axis2. (I have placed my .aar file in apache-tomcat-5.5.23\Axis2.war\WEB-INF\services). I need to read a properties file from my web service to read some text dynamically. Could sombody help me to know 1. Where should I place my properties file and 2. How do I specify the path for the properties file to read it in my web service java code. thanks in advance Best regards sanjeewa
I'm not 100% sure, but I believe they should go in the axis2 webapp class path (i.e. ...\tomcat\webapps\axis2\WEB-INF\classes) by default. I haven't needed to put them elsewhere, so I don't know how to configure it (web.xml?). If you put your files there, you shouldn't need to specify the path.
Try that and let me know if it works. I'd be interested in knowing 100% myself .
-- Nothing is impossible if I'mPossible
Joined: Apr 03, 2008
Thanks Doug I tried the location you have specified, (and some other locations as well) but wasn't successful. Once i could solve this, I'll let you know the solution. If any body else could help me on this please.... Thanks Best regards Sanjeewa
I had a related problem this week and my research often brought me to this thread so I thought I might post the solution I finally found here:
I am using Axis2 version 1.6.1 and the Axis2 standalone server. I have a JAX-WS annotated web service class, packaged with maven and put as a jar into the repository/servicejars folder.
Now I wanted to read in some database parameters from an external property file (so that I didn't have to redeploy the service when I wanted to change a user name for instance), but I couln't find the solution for a few days.
I tried several different ways to access the file and many possible locations, but always got the same NullPointerException.
Finally, on another forum I found the hint to use a FileWriter to check where the output went, and to my surprise it went straight to the axis root.
So I tried Paolos Code but put the file into the axis root folder and it worked! Then I put it to AXISROOT/conf/database/db.properties and used .getResourceAsStream("/conf/database/db.properties")); -- finally I had my solution.
Just thought I'd share this to help someone else who might have the same problem. ;)
subject: Reading a properties file from a Web service