“Premature end of file” error when Java read and writes XML data files

前端 未结 4 1988
余生分开走
余生分开走 2020-12-17 00:36

I have been using JDOM library to read and write XML files through Java Servlets.

Problem is that when I send many requests using AJAX to my servlets which read and

相关标签:
4条回答
  • 2020-12-17 00:43

    Try adding all the write requests to a Process Queue and then build/append XML by those elements of Queue.

    0 讨论(0)
  • 2020-12-17 00:50

    I have faced such type of problem but exactly not the same. I am sharing my experience about this error. Please, sorry for any inconvenience.

    I have faced the following problem

    1. I have to form a xml file with dynamic variable data. And post that xml to a URL by PostMethod in java.

    2. Normally It works. But when dynamic variable data is null. Then it shows the “Premature end of file".

    Solution:

    1. Just checking the variable is null or not. And it works for me.
    0 讨论(0)
  • 2020-12-17 00:56

    Two possible solutions are:

    • Write your files to thename.xml.part and then once done/closed to a rename to thename.xml, which makes the write closer to being atomic -- the reader can't read it until it's surely done so long as it is looking for ".xml" files only.
    • or, use a Database, atomicity is what they do.
    0 讨论(0)
  • 2020-12-17 01:02

    I have also faced this problem. My experience is...

    1. Clean Project
    2. Rebuild Project

    then it will run successfully....

    0 讨论(0)
提交回复
热议问题