• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Exception on invoking write() method twice on XSSFWorkbook instance.

 
Ranch Hand
Posts: 31
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I could see the same topic being covered at several places, but i dint get a clear picture from those.

Issue is,

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.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post an SSCCE (<- this is a link) that demonstrates the problem.
 
Renjith Panikar
Ranch Hand
Posts: 31
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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.

 
Renjith Panikar
Ranch Hand
Posts: 31
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
RESOLVED

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;
try{
workbook = new XSSFWorkbook(new ByteArrayInputStream(multipartFileBytes));
}catch(OfficeXmlFileException exception){
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.
reply
    Bookmark Topic Watch Topic
  • New Topic