引起原因:java.lang.ClassNotFoundException:org.apache.kafka.clients.producer.Callback

时间:2019-05-18 11:10:26

标签: dependencies mule classpath esb

我正在尝试按照本教程({{3进行配置),在Mavenized项目中的Windows环境中为Mule(Mule服务器3.9.1和Anypoint Studio 6.5.2,在我的类路径中)配置Apache Kafka日志记录}}):

“ Log4j2开箱即用,带有Kafka Appender,它允许开发人员将其日志消息定向到Kafka主题。”

我遵循了与上述步骤完全相同的步骤,并且还考虑了免责声明“ 注意:如果您在Studio中尝试,它将无法正常工作。当Mule启动时,它将首先加载其类,然后再加载任何应用程序”(这很有意义……服务器必须先启动,然后任何应用程序才能开始工作)。

因此,启动时必须在服务器的类路径中包含Kafka Clients库,否则您将在日志中获得许多ERROR条目,并且应用程序将正常启动。

我尝试了许多不同的方法以使其进入类路径(也将其包含在pom.xml中,该项目也构建良好,但正如免责声明中所述,它在运行时失败,并出现以下错误:

INFO  2019-05-18 13:00:15,866 [WrapperListener_start_runner] org.mule.module.launcher.MuleDeploymentService:
**********************************************************************
* Started domain 'default'                                           *
**********************************************************************
INFO  2019-05-18 13:00:15,884 [WrapperListener_start_runner] org.mule.module.launcher.ArtifactArchiveInstaller: Exploding a Mule artifact archive: file:/C:/Mule/apps/mave
ntestproject.zip
INFO  2019-05-18 13:00:16,558 [WrapperListener_start_runner] org.mule.module.launcher.application.DefaultMuleApplication:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ New app 'maventestproject'                               +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
INFO  2019-05-18 13:00:16,572 [WrapperListener_start_runner] org.mule.module.launcher.MuleApplicationClassLoader: [maventestproject] Loading the following jars:
=============================
file:/C:/Mule/apps/maventestproject/lib/kafka-clients-0.10.2.1.jar
file:/C:/Mule/apps/maventestproject/lib/lz4-1.3.0.jar
file:/C:/Mule/apps/maventestproject/lib/snappy-java-1.1.2.6.jar
=============================

ERROR 2019-05-18 13:00:16,947 [WrapperListener_start_runner] org.mule.module.launcher.DefaultArchiveDeployer:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Failed to deploy artifact 'maventestproject', see below  +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
java.lang.NoClassDefFoundError: org/apache/kafka/clients/producer/Callback
        at org.apache.logging.log4j.core.appender.mom.kafka.KafkaAppender$Builder.build(KafkaAppender.java:68) ~[log4j-core-2.8.2.jar:2.8.2]
        at org.apache.logging.log4j.core.appender.mom.kafka.KafkaAppender$Builder.build(KafkaAppender.java:53) ~[log4j-core-2.8.2.jar:2.8.2]
        at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:122) ~[log4j-core-2.8.2.jar:2.8.2]
        at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:952) ~[log4j-core-2.8.2.jar:2.8.2]
        at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:892) ~[log4j-core-2.8.2.jar:2.8.2]

在我的.m2文件夹中,存在以下内容:

C:\Users\user\.m2\repository\org\apache\kafka\kafka-clients\0.10.2.1\kafka-clients-0.10.2.1

从终端日志中可以看到,该jar也包含在项目中。但是不幸的是,在使用anypoint studio甚至是mule esb进行部署时,它仍然抱怨找不到该类。
我还将罐子添加到我的类路径中:

C:\Users\user\.m2\repository\org\apache\kafka\kafka-clients\0.10.2.1\kafka-clients-0.10.2.1.jar

我也尝试将jar文件添加到lib\boot并删除我的m2文件夹,返回依赖项等。但是没有结果。

研究了几个小时。有什么建议吗?

摘要:

  • 使用Maven构建顺利
  • 在运行时找不到类(但在项目和类路径中提供了jar,..)

0 个答案:

没有答案