Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8211439

Error messages when creating an XML file

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      Linux Mint 19
      java version "11" 2018-09-25
      Java(TM) SE Runtime Environment 18.9 (build 11+28)
      Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11+28, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      Creating an XML file with the attached source code works, but many error messages appear in the console

      REGRESSION : Last worked in version 10.0.2

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the source code and look at the console

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No error messages
      ACTUAL -
      Error messages

      ---------- BEGIN SOURCE ----------
      import java.io.FileNotFoundException;
      import java.io.FileOutputStream;

      import javax.xml.parsers.DocumentBuilderFactory;
      import javax.xml.parsers.ParserConfigurationException;
      import javax.xml.transform.Transformer;
      import javax.xml.transform.TransformerException;
      import javax.xml.transform.TransformerFactory;
      import javax.xml.transform.TransformerFactoryConfigurationError;
      import javax.xml.transform.dom.DOMSource;
      import javax.xml.transform.stream.StreamResult;

      import org.w3c.dom.Document;
      import org.w3c.dom.Element;

      public class XMLWarning {
      public static void main(String[] args) {
      try {
      Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
      Element rootEle = dom.createElement("doc");
      Element e = dom.createElement("val1");
      e.appendChild(dom.createTextNode("val2"));
      rootEle.appendChild(e);
      dom.appendChild(rootEle);
      Transformer transformer = TransformerFactory.newInstance().newTransformer();
      DOMSource domSource = new DOMSource(dom);
      StreamResult streamResult = new StreamResult(new FileOutputStream("Test.xml"));
      transformer.transform(domSource, streamResult);
      } catch (ParserConfigurationException | FileNotFoundException | TransformerException | TransformerFactoryConfigurationError e) {
      e.printStackTrace();
      }
      }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


            psonal Pallavi Sonal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: