1 2 Previous Next 18 Replies Latest reply on Aug 13, 2010 3:48 PM by 843834 Go to original post
      • 15. Re: Premature End Of File - SaxParseException
        I bet it is. I got a similar issue. But in my case I was trying to read and parse using streamreader (xml data).

        Surprisingly it worked fine on windows but usually failed on unix. Also I was using the same piece of code in two different applications in unix. One was working fine (suprisingly)

        Finally I cracked it :-) Guess what different versions of xerces.

        Please use xerces-J_1.4.0 to solve your problem. Hopefully you should fix this. (the other one had xercesimpl.2.x.x)

        • 16. Re: Premature End Of File - SaxParseException
          I was having the same issue and I figured it out.
          I was reading the xml file into a BufferedReader, then saving the line to a StringBuffer and printing it out ( to verify my info for testing)
          I then used the same InputStream and passed it to the DocumentBuilder.parse(inputstream)
          and got the error.
          What I had to do was reset the input stream but not by calling the reset method (tried and it didn't work)
          String servletURL = "http://localhost:8080/promoMover/MedicalInfoFinder?q=32323";
                   //Our URL for the servlet
                   URL url = null;
                   //Our input stream back from the servlet
                   InputStream is = null;
                   BufferedReader in = null;
                   String line = "";
                   StringBuffer xmlDoc = new StringBuffer();
                        url = new URL(servletURL);
                        is = url.openStream();
                        in = new BufferedReader(new InputStreamReader(is));
                        while ((line = in.readLine()) != null){
                        is = url.openStream(); //had to regather my input stream , I could have handle another way but this is for testing so the writing to xmlDoc is going away
                   }catch(MalformedURLException mue){
                        Logger.log(EClaimGlobalContext.getCORELogSpec(), 200, mue);
                   }catch(IOException ioe){
                   //Print the xml to system so we can view it, we can remove the Reader code afterwards
                   Document doc = null;
                        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                        DocumentBuilder builder = factory.newDocumentBuilder();
                        doc = builder.parse(is);
                   }catch(Exception e){
                        //Logger.log(EClaimGlobalContext.getCORELogSpec(), 200, e);
                        System.out.println("There was an error parsing the document " + e);
          • 17. Re: Premature End Of File - SaxParseException
            The premature read of file is caused by the closed of InputStream, try to read before close it and close after the read.
            • 18. Re: Premature End Of File - SaxParseException
              I could solve it the way you suggested . thanks !
              1 2 Previous Next