3

Problem reading Excel 2007 file .xlsx file extention, while I am trying to read with apache poi:

InputStream file = new FileInputStream(C:\\test.xlsx);

---> XSSFWorkbook workbook = new XSSFWorkbook(file);

This line giving me an exception Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlObject please, what can be cause of this error?

1
  • 1
    you have not included a library in your class path. Commented Oct 24, 2012 at 10:04

5 Answers 5

14

you need to include a jar file named xmlbeans-x.x.x.jar that comes under folder "your_location_of_poi\poi-x.x\ooxml-lib\" in your classpath.

Note: x.x is the version of poi that you are using and x.x.x is the version number of that jar file under the above mentioned folder

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

2 Comments

you can download that jar file from here java2s.com/Code/Jar/x/Downloadxmlbeansjar.htm by the way. Scroll down for other versions.
I am using a Linux virtual machine where Office is not installed. I have created a Swing Application for Excel reading. The app works fine in Windows but giving java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlException on Linux VM.
2

You download extra jar file. You can download :

http://www.findjar.com/index.x;jsessionid=D9C61BD4B98370C199118B8C53CC689F?query=org.apache.xmlbeans.XmlObject

Comments

1

You're missing the extra jar files that come with POI. Include them in your classpath.

Comments

0

You don't have XMLBeans in your classpath.

Comments

0

I downloaded xmlbeans.jar and added to Library as External Jar. It resolved my issue.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.