title: Best practice: Creation of SAX parser for XMLReader
body: <p>I'm using the Amazon S3 SDK in two separate wars running on the same Tomcat. I initialize an AmazonS3Client in the @PostConstruct of one of my Spring services.</p>
  
  <p>If I run these wars separately, everything usually works fine. If I run them together, one of them - the second one to start up - throws the following exception:</p>
  
  <blockquote>
    <p>com.amazonaws.AmazonClientException: Couldn't initialize a sax driver for the XMLReader</p>
  </blockquote>
  
  <p>I have a workaround where I set the following System property if this happens, after catching the AmazonClientException:</p>
  
  <pre><code>try {
    init();
  } catch (AmazonClientException ase) {
    System.setProperty("org.xml.sax.driver", "com.sun.org.apache.xerces.internal.parsers.SAXParser");
    init();
  }
  </code></pre>
  
  <p>But this is of course horrible. Is there a better way to do this? Why does this occur in these circumstances?</p>
  
  <p>UPDATE: At first, it seemed that moving the intitalization of the AmazonS3Client out of the @PostConstruct and initializing it lazily prevented this error completely. But apparently it still occurs sometimes - even when I only run one war instead of both.</p>