简体   繁体   English

java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory 问题

[英]java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory problem

I am new to itext7, I am using Elcipse IDE.我是 itext7 的新手,我正在使用 Elcipse IDE。 I downloaded all the itext7 jar files and added it to my libraries(classpath).我下载了所有 itext7 jar 文件并将其添加到我的库(类路径)中。 When I run my program(to convert text file to PDF file), I got the following error:当我运行我的程序(将文本文件转换为 PDF 文件)时,出现以下错误:

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at com.itextpdf.kernel.pdf.PdfPagesTree.<clinit>(PdfPagesTree.java:72)
at com.itextpdf.kernel.pdf.PdfCatalog.<init>(PdfCatalog.java:99)
at com.itextpdf.kernel.pdf.PdfCatalog.<init>(PdfCatalog.java:103)
at com.itextpdf.kernel.pdf.PdfDocument.open(PdfDocument.java:1958)
at com.itextpdf.kernel.pdf.PdfDocument.<init>(PdfDocument.java:284)
at com.itextpdf.kernel.pdf.PdfDocument.<init>(PdfDocument.java:265)
at TextFileToPDF.createPdf(TextFileToPDF.java:59)
at TextFileToPDF.main(TextFileToPDF.java:84)
`Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 8 more

If I add all the jar files to my libraries(ModulePath), then I got the following errors: Error: Unable to initialize main class TextFileToPDF Caused by: java.lang.NoClassDefFoundError: com/itextpdf/layout/element/IBlockElement If I add all the jar files to my libraries(ModulePath), then I got the following errors: Error: Unable to initialize main class TextFileToPDF Caused by: java.lang.NoClassDefFoundError: com/itextpdf/layout/element/IBlockElement

Does anybody knows how to fix this problem?有谁知道如何解决这个问题?

Thanks,谢谢,

  • Jo

I think you have forgot to add SL4j Library or jar into your project.我认为您忘记将 SL4j 库或 jar 添加到您的项目中。

It turns out that it missed the following 3 jars: slf4j.api, slf4j-log4j12, and log4j原来漏掉了下面3个jars:slf4j.api, slf4j-log4j12, and log4j

It works now after adding the above 3 jars.添加上述3个jars后,它现在可以工作了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.NoClassDefFoundError: OSGi 中的 org/slf4j/LoggerFactory - java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory in OSGi 休眠-java.lang.NoClassDefFoundError:org / slf4j / LoggerFactory - Hibernate - java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory Slf4j 和 Logback 错误:java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory - Slf4j and Logback error: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory Java:线程“ main”中的异常java.lang.NoClassDefFoundError:org / slf4j / LoggerFactory - Java: Exception in thread “main” java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory Spring工具套件中的线程“ main”中的异常java.lang.NoClassDefFoundError:org / slf4j / LoggerFactory - Exception in thread “main” java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory in Spring tool suite Gradle-线程“ main”中的异常java.lang.NoClassDefFoundError:org / slf4j / LoggerFactory - Gradle - Exception in thread “main” java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory XUGGLE ERROR:线程“main”中的异常java.lang.NoClassDefFoundError:org / slf4j / LoggerFactory - XUGGLE ERROR: Exception in thread “main” java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory 如何解决java.lang.NoClassDefFoundError:org / slf4j / LoggerFactory? - How can I resolve java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory? java.lang.NoClassDefFoundError:org / slf4j / LoggerFactory即使我有正确的依赖关系 - java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory even though I have the right dependencies RabbitMQ - 线程“main”中的异常java.lang.NoClassDefFoundError:org / slf4j / LoggerFactory - RabbitMQ - Exception in thread “main” java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM