Try getResourceAsStream() instead. That has the ability to read files within
a zip file.


-----Original Message-----
From: Subash Devkota [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, November 28, 2006 9:45 PM
To: axis-user@ws.apache.org
Subject: [Axis2] Problem reading own xml file inside aar archive

Hi,

I am having problem reading my own XML file inside aar file.
The structure of my archive file is as shown below:

    * META-INF
          o MANIFEST.MF
          o services.xml
    * security
          o XMLParser.class
          o serverConf.xml
          o ......
    * key.jks
    * services.properties

I want to read parameters inside serverConf.xml from XMLParser class. I 
have following code to read the xml file:

                URL  
url=XMLParser.class.getClassLoader().getResource("security/serverConf.xml");
                String fileName=url.toString();
               
                DocumentBuilderFactory docBuilderFactory = 
DocumentBuilderFactory.newInstance();
                DocumentBuilder docBuilder = 
docBuilderFactory.newDocumentBuilder();
                Document doc = docBuilder.parse (new File(fileName));

It works fine when i try it in java application from eclipse. But it has 
problem reading the file when i make archive and deploy as web service. 
I get the following error:

java.io.FileNotFoundException: 
jar:file:/home/oracle/app/jakarta-tomcat-5.0.28/webapps/axis2/WEB-INF/servic
es/SecureServer.aar!/security/serverConf.xml 
(No such file or directory)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:106)
        at 
org.apache.axiom.om.impl.dom.jaxp.DocumentBuilderImpl.parse(DocumentBuilderI
mpl.java:129)
        at security.XMLParser.loadXmlParameters(XMLParser.java:63)

Can anyone suggest me how can i solve the problem?

Thank You
Subash 
 
 
PRIVACY NOTICE

This email and any attachments may be confidential and/or privileged. Use of
the information contained in this email by anyone other than the intended
recipient is strictly prohibited. If you have received this email in error,
please notify the sender by replying to this message and delete this email.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to