[英]Jmeter cant read custom JAR depedencies
我写了一个 Maven 应用程序,我想在我的 Jmeter BeanShell 脚本中使用它。 The Maven application is using Google Guice 4.2.2
for dependecy injection and it is calling an API at the end (Code needs to perform some other operations before calling the API and thats why I am not using the JMETER Plugin). 我正在使用maven-shade-plugin
创建uber JAR (Fat JAR)。 当我从命令行运行 Jar 时,应用程序运行成功!
但是,当我在 Jmeter 测试计划中加载 JAR 并在 Jmeter BeanShell 中调用我的应用程序主方法时,我收到以下错误:
java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V
at com.google.inject.Key.ensureRetainedAtRuntime(Key.java:341) ~[load-testing.jar:?]
.
.
.
现在很多其他线程提到这可能是因为旧的 Google Guiva 版本(20.x 旧)但是从依赖树中我看到 Guava 版本是25.1-android
并且我可以从命令行成功运行我的 JAR !
Also I list the classes in the Uber JAR by runnung jar -tf
command and I can see that the com.google.common.base.Preconditions
class is there.
如果有人可以解决这个问题并帮助我解决这个问题,我会很高兴?
您的 fat-jar 似乎包含多个版本的 Guava(可能是由 shade-plugin 引起的)。
确保通过在每个 maven 模块中使用 Maven 依赖项管理将其锁定为单个版本。 ( https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Management )
Beanshell 本身可能有问题, 因为 JMeter 3.1 建议使用 JSR223 测试元素和 Groovy 语言进行脚本编写,原因在:
查看Apache Groovy - 为什么以及如何使用它文章了解更多详情。
我终于确认了我的评论。 The problem was my JAR Guava version was conflicting with Jmeter Guava version (which is 17.0) and Jmeter for some reason is picking up its own Guava version, after downgrading Guice version to 3.0
which does not depend on guava, I successfully ran my JAR through Jmeter。
为什么 Jmeter 用它自己的版本覆盖我的 JAR Guava 版本仍然是个谜。 我将使用 Jmeter 创建一张票,以便找到更多关于这个谜团的信息,但这个更改解决了我的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.