I am using apache poi to open an existing excel file.
public static int generateReport(Calendar csdate,Calendar cedate) throws Exception
{
FileInputStream fileIn =null;
FileOutputStream fileOut = null;
int sum=0;//For calculating the total number of tickets
final Workbook wb;
fileIn =new FileInputStream("d:\\excelfiles\\TicketsReport.xlsm");
wb = org.apache.poi.ss.usermodel.WorkbookFactory.create(fileIn);<-- Exception
final Sheet sheet = wb.getSheet("Report");
//rest of stuff
}
I have a servlet which takes the dates from an html page and call generateReport()
. The problem is this program was running previously with same tomcat 6
version and servlet2.4
version.In eclipse there is no compile time error at the WorkbookFactory.create()
line. Here's the stack trace.
java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/WorkbookFactory
at ReportFromJira.generateReport(ReportFromJira.java:59)
at JiraReportServlet.doPost(JiraReportServlet.java:52)
at JiraReportServlet.doGet(JiraReportServlet.java:36)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Unknown Source)
When I manually explored the jar files I found out that.
poi-3.8-20120326.jar contains
org.apache.poi.ss.usermodel->Workbook.class file
and poi-ooxml-3.8-20120326.jar contains
org.apache.poi.ss.usermodel->WorkbookFactory.class file
I have both the jar files included in my class path.
any idea why the exception?