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

Transformer.transform() throws java.lang.ExceptionInInitializerError

XMLWordPrintable

    • tiger
    • generic, sparc
    • generic, solaris_9
    • Verified

      Name: eaR10174 Date: 10/08/2001


        javax.xml.transform.Transformer.transform() throws java.lang.ExceptionInInitializerError
      when the default encoding is Cp037.
        
      This bug is found in the builds jdk1.4.0-beta3-b82, jaxp-1.1.3 and affects new JCK1.4 tests
        
      api/javax_xml/transform/Transformer/index.html#Transform[Transform001]
      api/javax_xml/transform/Transformer/index.html#GetSetParameter[GetSetParameter002]
      api/javax_xml/transform/Transformer/index.html#GetSetOProperties[GetSetOProperties002]
        
      To reproduce the bug do following:
        
        1. javac RunTest.java test.java
        2. java RunTest.java

      ------------------------------------RunTest.java--------------------------
      import java.io.*;

      public class RunTest {

          public static void main(String[] argv) {

              try {
                  String javaHome = System.getProperty("java.home");
                  String args[] = new String[3];
                  args[0] = javaHome + "/bin/java";
                  args[1] = "-Dfile.encoding=Cp037";
                  args[2] = "test";

                  Process p = Runtime.getRuntime().exec(args);
                  
                  BufferedReader inp = new BufferedReader(new
                          InputStreamReader(p.getInputStream(), "Cp037"));
                  BufferedWriter outp = new BufferedWriter(new
                          OutputStreamWriter(System.out, "ASCII"));
                  int c;

                  while ((c = inp.read()) != -1) {
                      outp.write(c);
                  }
                  outp.flush();

                  inp = new BufferedReader(new InputStreamReader(p.getErrorStream(),
                          "Cp037"));
                  outp = new BufferedWriter(new OutputStreamWriter(System.err,
                          "ASCII"));

                  while ((c = inp.read()) != -1) {
                      outp.write(c);
                  }
                  outp.flush();
                  
                  p.waitFor();
                  System.exit(p.exitValue());
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      }
      ------------------------------------test.java-----------------------------
      import javax.xml.transform.stream.StreamSource;
      import javax.xml.transform.stream.StreamResult;
      import java.io.StringReader;
      import javax.xml.transform.TransformerFactory;
      import javax.xml.transform.Transformer;

      public class test {

          public static void main (String[] args) {
              try {
                  String xml = "<?xml version='1.0'?><root/>";
      String xsl = "<?xml version='1.0'?>\n"
                             + "<xsl:stylesheet version='1.0'"
                             + " xmlns:xsl='http://www.w3.org/1999/XSL/Transform&#39;>\n"
                             + " <xsl:template match='/'>\n"
                             + "Test\n"
                             + " </xsl:template>\n"
                             + "</xsl:stylesheet>\n";

              
                  /* Create a TransformFactory instance */
                  TransformerFactory transformerFactory = TransformerFactory.newInstance();

                  StreamSource source = new StreamSource(new StringReader(xsl));
                  Transformer transformer = transformerFactory.newTransformer(source);
                  
                  transformer.transform(new StreamSource(new StringReader(xml)),
                          new StreamResult(System.out));
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      }
      ---------------------------------------------------------------------------
      ---------------------------------------------------------------------------
      % java -showversion RunTest
      java version "1.4.0-beta3"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b82)
      Java HotSpot(TM) Client VM (build 1.4.0-beta3-b82, mixed mode)

      ????????>??>?????/???_/?>??java.lang.ExceptionInInitializerError
              at java.lang.Class.forName0(Native Method)
              at java.lang.Class.forName(Class.java:135)
              at
      org.apache.xalan.serialize.SerializerFactory.getSerializer(SerializerFactory.java:127)
              at
      org.apache.xalan.transformer.TransformerImpl.createResultContentHandler(TransformerImpl.java:
      1007)
              at
      org.apache.xalan.transformer.TransformerImpl.createResultContentHandler(TransformerImpl.java:
      934)
              at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1083)
              at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1066)
              at test.main(test.java:27)
      Caused by: java.lang.RuntimeException: The resource [ XMLEntities.res ] could not load:
      java.lang.NumberFormatException: ??????>?????????>?????????/???????????????????????
       XMLEntities.res java.lang.NumberFormatException:
      ??????>?????????>?????????/???????????????????????
              at org.apache.xalan.serialize.CharInfo.<init>(CharInfo.java:202)
              at org.apache.xalan.serialize.SerializerToXML.<clinit>(SerializerToXML.java:292)
              ... 8 more
      ---------------------------------------------------------------------------
        
      ======================================================================

            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: