Skip to content
Advertisement

Unable to open XLSX file using Apache POI: NoClassDefFoundError

I’m having problems trying to open an XLSX file with Apache POI.

My code:

JavaScript

Exception thrown:

JavaScript

Background:

  • Running JDK 7 on MacOS X (Mavericks)
  • Using NetBeans
  • Imported jars (all from Apache POI binary distribution):
    • poi-3.11-20141221.jar
    • poi-ooxml-3.11-20141221.jar
    • poi-ooxml-schemas-3.11-20141221.jar
    • commons-codec-1.9.jar
    • log4j-1.2.17.jar

I can’t even start doing the real stuff, since I can’t even open the book! 🙁

When I saw the exception, I thought “Ok, let’s get xmlbeans and see if it works”, but xmlbeans is moved into Apache’s attic.

Am I missing something? How can I open the workbook?

Advertisement

Answer

I think you were right about needing xmlbeans-2.6.0.jar as well. That appears to be one of Poi’s dependencies. I set up a vestigial Maven project with poi, poi-scratchpad, poi-ooxml, and poi-ooxml-schemas as my direct dependencies. Maven yanked in these other JARs as dependencies:

  • commons-codec-1.9.jar
  • xmlbeans-2.6.0.jar
  • stax-api-1.0.1.jar

On further investigation, I see that stax-api is a transitive dependency for xmlbeans.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement