Hi,

I created a web services client using Axis v2.1.6.1, which uses the Axiom 
v1.2.12. I have a standalone java application invoking this web services client 
and passing CDATA string as one of the request parameter.

I found this from Axiom User Guide:
"When creating a new XMLInputFactory (resp. XMLInputFactory), StAXUtils looks 
for a property file named XMLInputFactory.properties (resp. 
XMLOutputFactory.properties) in the classpath, using the same class loader as 
the one from which the factory is loaded (by default this is the context 
classloader). If a corresponding resource is found, the properties in that file 
are applied to the factory using the XMLInputFactory#setProperty (resp. 
XMLOutputFactory#setProperty) method."

I have my XMLInputFactory.properties file with the following content:
javax.xml.stream.isCoalescing=false

I have a Unix shell script, which invokes my java application and that in turn 
calls the axis web services client.

I have tried various ways to get the XMLInputFactory.properties in my CLASSPATH


1)      Creating a separate jar file with just the XMLInputFactory.properties 
and adding that to the $CLASSPATH in the shell script

2)      Adding the absolute path of the XMLInputFactory.properties to $CLASSPATH

3)      Adding the properties file to my main java application jar file (in the 
root folder)

Nothing seems to work.

I wrote this program to test if XMLInputFactory.properties is getting loaded. 
Using Resource Bundle I am able to access XMLInputFactory.properties but not 
through ClassLoader.  I placed the properties file in the root folder of the 
"System.out.println(urls[i].getFile())" statement. That doesn't seem to work 
either. I created separate src and bin directories and put the properties file 
in the bin folder that doesn't work.

package com.dukenergy.mdm.xmlfactory.test;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Iterator;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.Properties;
import java.util.ResourceBundle;

public class XmlInputFactoryTest {

      private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
                  .getBundle("com.resources.XMLInputFactory");

      private void test() {
            ClassLoader loader = Thread.currentThread().getContextClassLoader();
            URL[] urls = ((URLClassLoader) loader).getURLs();

            for (int i = 0; i < urls.length; i++) {
                  System.out.println(urls[i].getFile());
            }
            try {
                  System.out.println(RESOURCE_BUNDLE
                              .getString("javax.xml.stream.isCoalescing"));
            } catch (MissingResourceException e) {
                  e.printStackTrace();
            }
            InputStream in = loader
                        .getResourceAsStream("XMLInputProperty.properties");
            if (in == null) {
                  System.out.println("InputStream instance is null");
            } else {
                  try {
                        Properties rawProps = new Properties();
                        rawProps.load(in);
                        for (Iterator it = rawProps.entrySet().iterator(); 
it.hasNext();) {
                              Map.Entry entry = (Map.Entry) it.next();
                              String strKey = (String) entry.getKey();
                              System.out.println("Key = " + strKey);
                              String strValue = (String) entry.getValue();
                              System.out.println("Value = " + strValue);
                        }
                  } catch (IOException ex) {
                        System.err.println("Failed to read 
XMLInputProperty.properties"
                                    + ex.getMessage());
                  } finally {
                        try {
                              in.close();
                        } catch (IOException ex) {
                              // Ignore
                        }
                  }
            }

      }
      public static void main(String[] args) {
            XmlInputFactoryTest xmlTest = new XmlInputFactoryTest();
            xmlTest.test();
      }
}

Any help to get this working is much appreciated.

Thanks,
Suresh

Reply via email to