Context: This is my first time working with java and importing jar files etc as this is for a school assignment.
Im pretty sure I have included all the jar files needed as I got them directly from the github page for iText7. I only intended to test this code to see if it would create a pdf file with the title and empty table inside but then I got this error which was pretty unexpected. I have 0 clue how to resolve it or what half of it even means.
This is the error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at com.itextpdf.commons.actions.ProductEventHandler.<clinit>(ProductEventHandler.java:52)
at com.itextpdf.commons.actions.EventManager.<init>(EventManager.java:42)
at com.itextpdf.commons.actions.EventManager.<clinit>(EventManager.java:37)
at com.itextpdf.kernel.pdf.PdfDocument.open(PdfDocument.java:1950)
at com.itextpdf.kernel.pdf.PdfDocument.<init>(PdfDocument.java:273)
at com.itextpdf.kernel.pdf.PdfDocument.<init>(PdfDocument.java:254)
at com.assignment.src.entities.report.ReportImpl.generateMonthlyReport(ReportImpl.java:182)
at com.assignment.src.entities.shared.Tests.main(Tests.java:83)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 8 more
The code in question:
public void generateMonthlyReport(LocalDateTime date) throws IOException {
StaffImpl si = new StaffImpl();
ArrayList<String[]> reportByMonth = this.getByMonth(date);
ArrayList<String[]> allTrainer = si.getByRole(Role.Trainer);
PdfWriter pw = new PdfWriter(FileSelection.MonthlyReport.toString());
PdfDocument pdf = new PdfDocument(pw);
Document doc = new Document(pdf);
PdfFont bold = PdfFontFactory.createFont(String.valueOf(FontStyles.BOLD));
// Adding Title
Paragraph title = new Paragraph("Monthly Report\n\n");
title.setFont(bold);
doc.add(title);
// Adding Table
float[] columnWidths = {150F, 150F, 150F, 150F, 150F, 150F};
Table table = new Table(columnWidths);
table.addCell("Trainer ID").setFont(bold);
table.addCell("Trainer Name").setFont(bold);
table.addCell("Sales").setFont(bold);
table.addCell("Commission").setFont(bold);
table.addCell("Revenue").setFont(bold);
table.addCell("Profit").setFont(bold);
doc.add(table);
doc.close();