0

I am using apache poi v3.9 and following statement is always giving classdefinitionnotfound exception

       HWPFDocument document=new HWPFDocument(file);


java.lang.ClassNotFoundException: org.apache.poi.hwpf.HWPFDocument
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
    at com.anz.actions.ConverterAction.execute(ConverterAction.java:39)
    at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
    at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
    at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
    at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
    at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305)
    at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
    at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    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:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    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:861)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Unknown Source)

Even though I have included all jars in my build path:

poi
poi-scratchpad
poi-ooxml
poi-ooxml-schemas 
poi-examples 
ooxml-schemas
5
  • Could you please confirm that you also include jars in the final WAR (I assume you run it on Tomcat), in the WEB-INF/lib folder? Commented Jul 23, 2013 at 12:12
  • Build path isn't enough, you need to get them into the WAR too! Commented Jul 23, 2013 at 12:15
  • Thanks lppiepiora right now I am doing all in eclipse.I believe v3.9 of POI is currupted but I am getting same error even after new library updates. Commented Jul 24, 2013 at 2:47
  • I would still guess that they are not included in WAR, when you go to Project Properties -> Java Build Path -> Order and Export, are the files marked as exported? They should be. Commented Jul 25, 2013 at 18:50
  • Acc to findjar.com (findjar.com/class/org/apache/poi/hwpf/HWPFDocument.html) you don't have the correct set of jars in your path. Commented Oct 10, 2017 at 12:37

1 Answer 1

1

Sometimes the libraries may get corrupted... please remove all jars and add again, clean and run the app..

Sign up to request clarification or add additional context in comments.

2 Comments

Thank You Sankumarsingh, I strongly believe the jar is corrupted but I am not able to find poi v3.8 or below. I downloaded poi3.9 libraries multiple times and updated to build path everytime it is giving same exception.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.