Discussion:
java.lang.ClassNotFoundException: org.apache.poi.ss.usermodel.WorkbookFactory
coisox
2011-11-25 02:41:35 UTC
Permalink
I include all .jar from poi-3.8-beta4 folder. My code like below:

import org.apache.poi.ss.usermodel.*;

InputStream inputStream = new FileInputStream("C:\\file.xls");
Workbook wb = WorkbookFactory.create(inputStream);
return wb.toString();

The code has no error but when i run my application, i got
java.lang.ClassNotFoundException:
org.apache.poi.ss.usermodel.WorkbookFactory

Why? I already include the library and the code can read it (coz no error)
and rebuild the eclipse workspace but when runtime it can't be reached?

The same goes if i use org.apache.poi.extractor.ExtractorFactory with
ExtractorFactory.createExtractor(file).

--
View this message in context: http://apache-poi.1045710.n5.nabble.com/java-lang-ClassNotFoundException-org-apache-poi-ss-usermodel-WorkbookFactory-tp5021705p5021705.html
Sent from the POI - User mailing list archive at Nabble.com.
Sergey Maslov
2011-11-25 04:09:23 UTC
Permalink
Are you sure the project was rebuild completely? Eclipse could show no
code errors but can`t build the project for some reasons (missing
dependencies, for example). So the old class files could be used (or
some class files could be not created at all). Eclipse has "Problems"
tab showing current compilation. and building problems. Check the
content of it.
Post by coisox
import org.apache.poi.ss.usermodel.*;
InputStream inputStream = new FileInputStream("C:\\file.xls");
Workbook wb = WorkbookFactory.create(inputStream);
return wb.toString();
The code has no error but when i run my application, i got
org.apache.poi.ss.usermodel.WorkbookFactory
Why? I already include the library and the code can read it (coz no error)
and rebuild the eclipse workspace but when runtime it can't be reached?
The same goes if i use org.apache.poi.extractor.ExtractorFactory with
ExtractorFactory.createExtractor(file).
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/java-lang-ClassNotFoundException-org-apache-poi-ss-usermodel-WorkbookFactory-tp5021705p5021705.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
coisox
2011-11-25 04:52:38 UTC
Permalink
OMG!!! After 2 days cracking my head, u r right! No wonder i can't find
similar prob in google.

Actually what I did was (when the error happen):
1. Copy "poi-3.8-beta4" folder into my project "WEB-INF\lib"
2. Refresh eclipse project explorer
3. Eclipse > Project properties > Libraries > add all poi3.8 jar
4. Eclipse > Project properties > Libraries > remove old jar which has
similar initial name with poi3.8 files
5. Rebuild working space

I thought eclipse render some xml file to manage the library (hence ignoring
the jar hierarchy/folder) but it's not. Then what i did:

1. Copy only jar files from "poi-3.8-beta4" folder into my project
"WEB-INF\lib"
2. Refresh eclipse project explorer
3. Eclipse > Project properties > Libraries > add all poi3.8 jar
4. Eclipse > Project properties > Libraries > remove old jar which has
similar initial name with poi3.8 files
5. Delete old jar from "WEB-INF\lib"
6. Rebuild working space

Then its working!

--
View this message in context: http://apache-poi.1045710.n5.nabble.com/java-lang-ClassNotFoundException-org-apache-poi-ss-usermodel-WorkbookFactory-tp5021705p5021867.html
Sent from the POI - User mailing list archive at Nabble.com.

Loading...