2 Replies Latest reply on Mar 18, 2011 9:22 PM by user263926

    org.xml.sax.SAXParseException: Premature end of file

    user263926
      We are upgrading application from weblogic 8.1 to weblogic 10.3.2. When a jsp loaded, which has an xsl, below exception is thrown in weblogic console.

      Tried replacing latest xalan & xercesImpl jar files. But still getting the exception. Please let me know root caue and any solution for this.


      <Error> <netuix> <BEA-423405> <An exception [javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.sax.SAXParseException: Premature end of file.] was thrown while rendering the content at [questionsByPage.jsp].
      javax.servlet.ServletException: javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.sax.SAXParseException: Premature end of file.
      at weblogic.servlet.jsp.PageContextImpl.handlePageException(PageContextImpl.java:417)
      at jsp_servlet._questionsbypage._jspService(__questionsbypage.java:821)
      at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
      at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
      at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
      Truncated. see log file for complete stacktrace

      Caused By: javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.sax.SAXParseException: Premature end of file.
      at org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:683)
      at org.apache.taglibs.standard.tag.common.xml.TransformSupport.doStartTag(TransformSupport.java:145)
      at jsp_servlet._questionsbypage._jspService(__questionsbypage.java:658)
      at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
      at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
      Truncated. see log file for complete stacktrace

      Caused By: javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.sax.SAXParseException: Premature end of file.
      at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:807)
      at org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:666)
      at org.apache.taglibs.standard.tag.common.xml.TransformSupport.doStartTag(TransformSupport.java:145)
      at jsp_servlet._questionsbypage._jspService(__questionsbypage.java:658)
      at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
      Truncated. see log file for complete stacktrace
        • 1. Re: org.xml.sax.SAXParseException: Premature end of file
          René van Wijk
          SAX uses the InputSource class to parse XML. If you look at the javadocs of InputSource (http://download.oracle.com/javase/1.5.0/docs/api/org/xml/sax/InputSource.html),
          the following can be noted:

          An InputSource object belongs to the application: the SAX parser shall never modify it in any way (it may modify a copy if necessary).
          However, standard processing of both byte and character streams is to close them on as part of end-of-parse cleanup, so applications
          should not attempt to re-use such streams after they have been handed to a parser.

          This means you cannot reuse the inputstream (it is already closed) created by the InputSource, you have to make copies to the input stream for each call to the SAX parser.
          • 2. Re: org.xml.sax.SAXParseException: Premature end of file
            user263926
            Below is the code which parses the xsl file,

            <utility:notNull item="<%=docs%>">
            <utility:forEachInArray counterId="docNum" id="doc" type="com.bea.content.Node" array="<%=docs%>">
            <x:transform xslt="${xslFile}">
            <x:param name="docNum"><%=docNum.toString()%></x:param>
            <cm:getProperty name="_content" node="<%=doc%>" />
            </x:transform>
            </utility:forEachInArray>
            </utility:notNull>

            Below tag libraries are used,

            <%@ taglib uri="http://www.bea.com/servers/portal/tags/personalization" prefix="pz"%>
            <%@ taglib uri="http://www.bea.com/servers/p13n/tags/utility" prefix="utility"%>
            <%@ taglib uri="http://www.bea.com/servers/portal/tags/content" prefix="cm"%>