I keep getting the following error trying to use a PDF lib and not having any luck. I am using spring and maven. I have tried pdfbox and itextpdf.
I get the Following error with either one ( obv the class part is different ) org.apache.cxf.interceptor.Fault: com/itextpdf/text/Document Caused by: java.lang.NoClassDefFoundError: com/itextpdf/text/Document
pom
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.14</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.itextpdf/itextpdf -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.13</version>
</dependency>
Class
import com.itextpdf.text.Document;
public enum PDFController {
INSTANCE;
PDFController() {
}
public void testPDF() {
// Error happens here
Document doc = new Document();
}
}
It appears Maven is adding the correct jars. So why can it not find the class?
I believe I have it fixed. I am used IntelliJ and under Project Structure -> Artificats -> Output Layout.
My Jars I was adding with Maven were getting added to the "Available Elements" area. I had to move them into the Web-INF/lib folder.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.