首页 > 解决方案 > Jmeter 无法加载类 com.azure.messaging.eventhubs.EventDataBatch

问题描述

我的系统中安装了 JMeter 5.2.1。当我尝试执行下面的代码时,我收到了这个错误。

响应消息:javax.script.ScriptException:org.codehaus.groovy.control.MultipleCompilationErrorsException:启动失败:类生成期间的一般错误:java.lang.NoClassDefFoundError:由于缺少而无法加载类 com.azure.messaging.eventhubs.EventDataBatch依赖 org/apache/qpid/proton/amqp/messaging/Section

代码:import com.azure.messaging.eventhubs.*

final String connectionString = 'EVENT HUBS NAMESPACE CONNECTION STRING'
final String eventHubName = 'EVENT HUB NAME'

// create a producer using the namespace connection string and event hub name
EventHubProducerClient producer = new EventHubClientBuilder()
    .connectionString(connectionString, eventHubName)
    .buildProducerClient()

// prepare a batch of events to send to the event hub
EventDataBatch batch = producer.createBatch()
batch.tryAdd(new EventData('Fifth event'))

// send the batch of events to the event hub
producer.send(batch)

// close the producer
producer.close()

以下是我在 LIB 文件夹中拥有的依赖库。如果我缺少任何依赖项或使用错误的版本依赖项,请告诉我。amqp-client-5.7.1.jar azure-core-1.13.0.jar azure-core-amqp-2.0.2.jar azure-core-test-1.5.3.jar azure-eventhubs-3.2.2.jar azure -identity-1.2.3.jar azure-messaging-eventhubs-5.5.0.jar jackson-annotations-2.9.0.jar jackson-core-2.9.9.jar jackson-databind-2.9.9.jar jackson-dataformat- xml-2.9.9.jar jackson-datatype-jsr310-2.9.9.jar jackson-module-jaxb-annotations-2.9.9.jar junit-jupiter-api-5.6.3.jar junit-jupiter-engine-5.6。 3.jar junit-jupiter-params-5.6.3.jar mockito-core-3.3.3.jar proton-j-0.31.0.jar qpid-proton-j-extensions-1.2.1.jar reactive-streams-1.0 .3.jar reactor-core-3.3.12.RELEASE reactor-test-3.3.12.RELEASE slf4j-api-1.7.28 stax2-api-3.1.4 woodstox-core-5.1.0

标签: jmeter

解决方案


proton-j-0.33.4.jar中的org/apache/qpid/proton/amqp/messaging/Section生命

我不知道你从哪里得到你proton-j-0.31.0.jar的,我的期望是你应该坚持使用Microsoft Azure 事件中心客户端库 » 5.5.0并使用MavenIvy等依赖管理系统来获取包含所有依赖关系的库包括传递的。

获得它们后 - 将所有 .jar 文件复制到 JMeter 安装的“lib”文件夹(或JMeter Classpath上的其他位置)并重新启动 JMeter 以获取更改

以防万一列表应该如下所示:

azure-core-1.13.0.jar
azure-core-amqp-2.0.2.jar
azure-messaging-eventhubs-5.5.0.jar
jackson-annotations-2.11.3.jar
jackson-core-2.11.3.jar
jackson-databind-2.11.3.jar
jackson-dataformat-xml-2.11.3.jar
jackson-datatype-jsr310-2.11.3.jar
jackson-module-jaxb-annotations-2.11.3.jar
jakarta.activation-api-1.2.1.jar
jakarta.xml.bind-api-2.3.2.jar
netty-tcnative-boringssl-static-2.0.35.Final.jar
proton-j-0.33.4.jar
qpid-proton-j-extensions-1.2.3.jar
reactive-streams-1.0.3.jar
reactor-core-3.3.12.RELEASE.jar
slf4j-api-1.7.30.jar
stax2-api-4.2.1.jar
woodstox-core-6.2.1.jar

另请注意,根据 JMeter 最佳实践,您应该始终使用最新版本的 JMeter,因此请考虑尽快升级到JMeter 5.4 (或JMeter 下载页面上提供的最新版本)。


推荐阅读