title: org.apache.xerces.dom.DeferredDocumentImpl incompatible with org.dom4j.Document
body: <p>Im reading some RSS from an URL and are experiencing some troubles.
  Initially I had a straightforward implementation like this:</p>
  
  <pre><code>SAXReader reader = new SAXReader();
  Document doc = reader.read(new URL(sURL));
  </code></pre>
  
  <p>However, this didnt allow me to timeout the request if the response was very slow. So I changed it to :</p>
  
  <pre><code>public static org.dom4j.Document readXml(InputStream is) throws SAXException, IOException,
          ParserConfigurationException {
          DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  
          dbf.setValidating(false);
          dbf.setIgnoringComments(false);
          dbf.setIgnoringElementContentWhitespace(true);
          dbf.setNamespaceAware(true);
  
          DocumentBuilder db = null;
          db = dbf.newDocumentBuilder();
  
          return (org.dom4j.Document)db.parse(is);
      }
  
       SAXReader reader = new SAXReader();
  
      URL myUrl = new URL(sURL);
      URLConnection c = myUrl.openConnection();
      c.setConnectTimeout(10000);
      c.setReadTimeout(10000);
      org.dom4j.Document doc = readXml(c.getInputStream());
      Element root = doc.getRootElement();
  </code></pre>
  
  <p>When trying this, I get a annyoing error:</p>
  
  <pre><code>org.apache.xerces.dom.DeferredDocumentImpl incompatible with org.dom4j.Document
  </code></pre>
  
  <p>How can I avoid this? None of the above methods are supposed to return that type of Document, and I also try to cast to the correct document type..</p>
  
  <p>EDIT: The problem is db.parse(is) which returns org.w3c.dom ..</p>