1

I have a large project with lots of dependencies packaged as a 'jar-with-dependencies.jar'. I place this jar in jmeter's /lib folder.

When I try to start Jmeter and open a jmx file I get Uncaught exception error like,

Uncaught Exception java.lang.NoSuchMethodError: com.thoughtworks.xstream.core.JV
M.newReflectionProvider()Lcom/thoughtworks/xstream/converters/reflection/Reflect
ionProvider;.See log file for details.

I plan to write a BeanShell Java code that would use the functionalities within the custom jar imported. Am I importing the jar in the right way? Is there any other way to import the jar?

Cœur
  • 37,241
  • 25
  • 195
  • 267
user2626431
  • 447
  • 1
  • 10
  • 20

1 Answers1

2

This class is contained in the xstream.jar, and JMeter already has its own version of xstream.jar (JMeter 2.13 and 3.0 include xstream-1.4.8.jar).

Now, if your Jar with dependencies has another version of xstream.jar, you will have 2 versions of this file in lib folder. And that's not good:

the behavior is undetermined and only at runtime one of the two classes will be chosen. Which one gets chosen depends on the internal implementation of the class loader, there is no way to know upfront.

So you need to remove one of the files. Which one is tricky

  • Usually keeping the newer version is a safer option. So I'd start from that. If it works - great.
  • If it doesn't work, try the other way around (although I suspect the error you are seeing coming from some older version of this package)
  • If second method doesn't work, you will have to open up the code of your custom jar, and update it to be compatible with JMeter (update version of xstream.jar to be the same as JMeter uses, and update any broken code). Or you can try this solution.
Community
  • 1
  • 1
timbre timbre
  • 12,648
  • 10
  • 46
  • 77