1 Reply Latest reply on Feb 2, 2010 8:58 AM by Shivey Upadhyay

    Strange behaviour of org.xml.sax.EntityResolver.resolveEntity method on JBOSS

    Shivey Upadhyay Newbie

      Hi,

       

      The peice of code that i want to discuss, parses a custom XML using SAXParser. The main class contains following code:


      SAXParserFactory parserFactory = SAXParserFactory.newInstance();
      parserFactory.setValidating(false);
      SAXParser parser=parserFactory.newSAXParser();
      XMLReader reader = parser.getXMLReader();
      reader.setEntityResolver(new CustomEntityResolver());
      reader.setContentHandler(new MyContentHandler());
      InputSource is = new InputSource(this.getClass().getResourceAsStream("my.xml"));
      reader.parse(is);


      The class CustomEntityResolver implements org.xml.sax.EntityResolver and gives definition for method

      public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
      InputStream iStream = this.getClass().getResourceAsStream(systemId);
      InputSource iSource = new InputSource(is);
      return iSource;
      }

      and my.xml starts with
      <? xml ver...?>
      <!DOCTYPE SYSTEM "shivey.dtd">

      the ARGUMENT systemId comes as "shivey.dtd" on weblogic-- as defined in XML, BUT when the same application is executed on JBOSS 4.0.2, the value for systemId comes as "file:///JBOSS_HOME/bin/shivey.dtd" and hence I GET A MalformedURLException.

       

      Observation: The iStream(InputStream) object created on Weblogic is of java.io.BufferedStream, but same object is of type sun.net.www.protocol.jar.JarURLConnection$JarURLInputStream if systemId is hardcoded(shivey.dtd) on Jboss.

       

      I appreciate any help in advance.

       

      Thanks again,
      Shivey Upadhyay