Workbook object creation error: content stream closed

Hi all,

I have wrote a java service that gets executed from an email port whenever a email comes with an xlsx attachment.
I am extracting the attachment from the mail in my java service and reading its content in a bufferedinput stream.
I am getting error while creating a workbook object for that attachment object.
Below is the code where i am getting error:

IDataCursor pipelineCursor = pipeline.getCursor();
Object inputStream = IDataUtil.get( pipelineCursor, “inputStream” );
BufferedInputStream bufferedInputStream = new BufferedInputStream( (InputStream) inputStream );
if (bufferedInputStream == null)
throw new ServiceException(“Input File Stream is Null”);

IData[] row_list = null;
String debugLog = null;
Workbook wb = null;
debugLog = “Workbook Object Creation”;
wb = new XSSFWorkbook(bufferedInputStream); // error at this step.
Sheet sheet = wb.getSheetAt(0);

The input to this java service is an object containing the xlsx attachment.

I am having following jars in my classpath:

  • poi-3.6-20091214.jar
  • poi-contrib-3.6-20091214.jar
  • poi-ooxml-3.6-20091214.jar
  • poi-ooxml-schemas-3.6-20091214.jar
  • dom4j-1.6.1.jar

Can anyone of you please help me to resolve this issue.?

Thanks in Advance…


I finally found the solution:
there werte 2 jar files missing in IS classpath.
· xmlbeans-2.3.0.jar
· org.apache.servicemix.specs.stax-api-1.0-1.0.1

After adding these jar files code ran fine.

I hope this might be useful for others.