Reputation: 977
I get the error: Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlObject
I get that error when I am trying to open an excel file using java. See the code below. I have downloaded the lib Log4J and included the jar file in my class path. What should I do to make this work?
try {
FileInputStream file = new FileInputStream(new File(C:/Users/myname/Desktop/result/Test1.xlsx));
// Create Workbook instance holding reference to .xlsx file
XSSFWorkbook workbook = new XSSFWorkbook(file);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
The Pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>RemoveBlankspaceFromExceldocuments</groupId>
<artifactId>RemoveBlankspaceFromExceldocuments</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</project>
Upvotes: 1
Views: 6196
Reputation: 103
Try the following:
It solved the Exception in thread AWT-EventQueue-0 java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlObject issue.
Hope it will work for sure!
Upvotes: 1
Reputation: 200158
Apparently you are not using Maven to manage your library dependencies. You seem to have included the Apache POI library, but not its transitive dependencies, one of which is Apache XML Beans. I would highly recommend not continuing without Maven, Gradle, or another dependendy management system.
Upvotes: 1