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

Can't create Transformer, Templates objects if system properties are readonly

XMLWordPrintable

    • b26
    • generic
    • generic
    • Verified

      Name: eaR10174 Date: 08/25/2003


        Instances of Transformer, Templates are not created if the installed security manager does not
      allow to modify the system properties (See test.java below). TransformerConfigurationException contains
      the following message:

           javax.xml.transform.TransformerException: org.xml.sax.SAXException: Can't create default XMLReader;
           is system property org.xml.sax.driver set?


       If the security manager allows to modify the system properties and the property 'org.xml.sax.driver' is
      not set then the property is set after the instances of Transformer, Templates are created.

        The bug appears in jdk1.5.0beta-b16 and affects old JCK1.4a tests that fail during testing in singleJVM
      mode (JavaTest harness sets own security manager that prohibits properties modification in this mode):
        
         api/javax_xml/transform/ErrorListener/index.html#Error[Error001]
         api/javax_xml/transform/Templates/index.html#NewTransformer[NewTransformer001]
         api/javax_xml/transform/sax/TransformerHandler/index.html#SystemId
         api/javax_xml/transform/sax/SAXTransformerFactory/index.html#newXMLFilter
         api/javax_xml/transform/sax/SAXTransformerFactory/index.html#Feature[Feature002]
         api/javax_xml/transform/dom/DOMResult/index.html#GetSetNode[GetSetNode002]
         api/javax_xml/transform/Transformer/index.html#GetSetParameter[GetSetParameter002]
         api/javax_xml/transform/TransformerFactory/index.html#NewTemplates[NewTemplates001]
         api/javax_xml/transform/URIResolver/index.html#Resolve[Resolve001]
         api/javax_xml/transform/Transformer/index.html#Transform[Transform001]
         api/javax_xml/transform/sax/TransformerHandler/index.html#getTransformer
         api/javax_xml/transform/TransformerFactory/index.html#NewTransformer[NewTransformer002]
         api/javax_xml/transform/sax/SAXTransformerFactory/index.html#newHandler[newHandler103]
         api/javax_xml/transform/sax/SAXTransformerFactory/index.html#newHandler[newHandler104]
         api/javax_xml/transform/Transformer/index.html#GetSetOutputProperty[GetSetOutputProperty002]
         api/javax_xml/transform/Transformer/index.html#GetSetOutputProperty[GetSetOutputProperty005]
         api/javax_xml/transform/Templates/index.html#GetOutputProperties
         api/javax_xml/transform/Transformer/index.html#GetSetOProperties
         
            
      ------------------------------------test.java-----------------------------
      import java.io.PrintWriter;
      import java.io.StringReader;
      import javax.xml.transform.Templates;
      import javax.xml.transform.TransformerConfigurationException;
      import javax.xml.transform.TransformerFactory;
      import javax.xml.transform.stream.StreamSource;


      public class test {

          /* standalone interface */
          public static void main(String argv[]) {
              new test().run();
          }
          
          public void run() {
              String xslData = "<?xml version=\"1.0\"?>" +
                               "<xsl:stylesheet" +
                               " xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"" +
                               " version=\"1.0\"" +
                               ">" +
                               " <xsl:template match=\"/\">" +
                               " Hello World! \n" +
                               " </xsl:template>" +
                               "</xsl:stylesheet>";

                               
              System.setSecurityManager(new SecurityManager());

              /* Create a transform factory instance */
              TransformerFactory tfactory = TransformerFactory.newInstance();
                  
              /* Create a StreamSource instance */
              StreamSource streamSource = new StreamSource(new StringReader(xslData));
              

              try {
                  tfactory.newTransformer(streamSource);
                  
                  System.out.println("OK");
              } catch (TransformerConfigurationException e) {
                  System.out.println("newTransformer(): " + e);
              }

              try {
                  tfactory.newTemplates(streamSource);
                  
                  System.out.println("OK");
              } catch (TransformerConfigurationException e) {
                  System.out.println("newTemplates(): " + e);
              }

          }
      }
      --------------------------------------------------------------------------
      % java -showversion test
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b16)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b16, mixed mode)

      newTransformer(): javax.xml.transform.TransformerConfigurationException:
      javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException:
      org.xml.sax.SAXException: Can't create default XMLReader; is system property org.xml.sax.driver set?
      newTemplates(): javax.xml.transform.TransformerConfigurationException:
      javax.xml.transform.TransformerException: org.xml.sax.SAXException: Can't create default XMLReader;
      is system property org.xml.sax.driver set?
      ---------------------------------------------------------------------------

      ======================================================================

            ayadavsunw Arun Yadav (Inactive)
            evgsunw Evg Evg (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: