I could see the same topic being covered at several places, but i dint get a clear picture from those.
I have a download link in JSp page to download excel file. I have this file in HTTPSession.
To pop up save excel box, i invoked write(OutputStream) on XSSFWorkbook instance.
But when i click on the link for the second time, this exception occoured.
Request processing failed; nested exception is org.apache.xmlbeans.impl.values.XmlValueDisconnectedException
it will be really helpful if some one can help me to resolve it.
First time when the user clicks the link, a pop up will come asking the user to save/open the file.
User will click on the download link again, if he close the file by mistake.
This time, it will not give a pop up and an exception "Request processing failed;
nested exception is org.apache.xmlbeans.impl.values.XmlValueDisconnectedException " can be
seen on console. This exception occours when we invoke .write(OutputStream) on
same Workbook instance for the second time. Hpe this give a clear picture.
This is what i did to resolve it.
Instead of keeping the Workbook in session, I took getBytes() from MultipartFile (File uploaded) and kept it in session.
Validation errors are also uploaded to session.
Now I have both Original file and errors in session.
I will create a new XSSFWorkbook instance from the following code.
Workbook workbook = null;
workbook = new XSSFWorkbook(new ByteArrayInputStream(multipartFileBytes));
workbook = new HSSFWorkbook(new ByteArrayInputStream(multipartFileBytes));
Now, workbook.write(OutputStream) will be invoked on different instances of Workbook on each request.
Let me know if you see any issues in this approach.