When I'm attempt to use the class XWPFDocument to open a specific file, is return me a error message: javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/apache/poi/wp/usermodel/Paragraph. Here is the line code: XWPFDocument doc = new XWPFDocument(OPCPackage.open(MyClass.class.getResourceAsStream(fileName)));
You are likely missing the "poi-scratchpad-XXX.jar" library of POI in your classpath which holds some of the classes that are necessary for working with Word Documents.
I'm have using maven to get the necessary libraries... in my pom.xml I have the following: <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.11</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.11</version> </dependency> What is wrong?
sorry, where reads <version>3.11</version> consider: <version>3.12</version>
Try adding <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-scratchpad</artifactId> <version>3.12</version> </dependency>
FYI, the requirement on scratch-jar is not intended, but unfortunately made it into 3.12, newer releases will have this dependency removed again, see bug 57963 for this.
Tks, Dominik. It works beautifully for me!