Created attachment 24802 [details] The java class ExcelObj.java that is referenced in the bug text I have a web application that uses our ExcelObj.java (code attached) to write an Excel file. When it reaches the line wb.write(fOut); it stops with this exception: java.lang.NullPointerException at org.apache.xmlbeans.impl.store.Xobj.array_setter(Xobj.java:2401) at org.apache.xmlbeans.impl.values.XmlComplexContentImpl.arraySetterHelper(XmlComplexContentImpl.java:1055) at org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTWorksheetImpl.setColsArray(Unknown Source) at org.apache.poi.xssf.usermodel.XSSFSheet.write(XSSFSheet.java:2297) at org.apache.poi.xssf.usermodel.XSSFSheet.commit(XSSFSheet.java:2287) at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:177) at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:181) at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:214) at gov.bls.dbes.sled.util.ExcelObj.close(ExcelObj.java:110) at gov.bls.dbes.sled.util.ExcelWriter.writeExcelFile(ExcelWriter.java:296) at gov.bls.dbes.sled.util.ExcelWriter.writeExcelFile(ExcelWriter.java:352) at gov.bls.dbes.sled.action.ProcessNewExcelAction.outputExcel(ProcessNewExcelAction.java:231) at gov.bls.dbes.sled.action.ProcessNewExcelAction.writeOutExcel(ProcessNewExcelAction.java:125) at gov.bls.dbes.sled.action.ProcessNewExcelAction.execute(ProcessNewExcelAction.java:80) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525) at javax.servlet.http.HttpServlet.service(HttpServlet.java:763) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3241) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2010) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1916) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1366) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209) at weblogic.work.ExecuteThread.run(ExecuteThread.java:181) HOWEVER when I alter the single line wb = new XSSFWorkbook(); to be wb = new HSSFFWorkbook(); (in other words, to use HSSF rather than XSSF) the execution finishes normally.
Can you submit a unit test reproducing the problem? The test code should use ExcelObj and throw exception as described. The following simple code works fine with the latest POI-3.6: ExcelObj obj = new ExcelObj(); obj.open("First Argument", "Header String", "Footer String"); obj.startRow(2); obj.setCell("test"); obj.close(); I guess the problem happens only with a certain combination of input arguments and method calls. So, we need more information to help you. Also, which version of POI are you using? The lines in the stack trace differ from current code. Please try the latest POI-3.6 or the latest build from trunk. Nightly builds can be downloaded from http://encore.torchbox.com/poi-svn-build/ Yegor
This bug turned out *not* to be a problem with POI, but with a feature of running the web application using WebLogic Server. The XSSF POI api uses classes contained in the xmlbeans jar file. I *did* have a reference to the (correct) xmlbeans jar file as an “external jar file” referenced in my Weblogic project. But behind the scenes Weblogic Server uses some Weblogic-specific jar files that it searches first during execution. One of those WebLogic-specific jar files includes the same packages that are in the xmlbeans jar file. This produced the reported error results when the application was run. Once I was aware of that problem I achieved error-free execution by adding the correct xmlbeans jar file to the very beginning of the classpath used to run WebLogic Server. For me that jar file is xmlbeans-2.3.0.jar.