Home > Software design >  Jmeter - Java Request Custom Sampler with Spring Boot java client - throws NoClassDefFoundError
Jmeter - Java Request Custom Sampler with Spring Boot java client - throws NoClassDefFoundError

Time:04-21

Written Java Custom Sampler of JMeter, which will accept a string from the JMeter tool. I need to pass this to a Spring Boot Application which is a simple Java client program. Once I packaged the jars, and I placed it in /lib/ext folder of JMeter, during startup I am getting the below issue. Any one please help on this.

2022-04-18 22:56:39,865 DEBUG o.a.j.r.ClassFinder: BOOT-INF/classes/com/**/**/JmsSamplerClient (wrong name: com/**/**/JmsSamplerClient)
java.lang.NoClassDefFoundError: BOOT-INF/classes/com/**/**/JmsSamplerClient (wrong name: com/**/**/JmsSamplerClient)
    at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_192]
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[?:1.8.0_192]
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[?:1.8.0_192]
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:468) ~[?:1.8.0_192]
    at java.net.URLClassLoader.access$100(URLClassLoader.java:74) ~[?:1.8.0_192]
    at java.net.URLClassLoader$1.run(URLClassLoader.java:369) ~[?:1.8.0_192]
    at java.net.URLClassLoader$1.run(URLClassLoader.java:363) ~[?:1.8.0_192]
    at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_192]
    at java.net.URLClassLoader.findClass(URLClassLoader.java:362) ~[?:1.8.0_192]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_192]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_192]
    at java.lang.Class.forName0(Native Method) ~[?:1.8.0_192]
    at java.lang.Class.forName(Class.java:348) ~[?:1.8.0_192]
    at org.apache.jorphan.reflect.ClassFinder$ExtendsClassFilter.isChildOf(ClassFinder.java:100) ~[jorphan.jar:5.4.3]
    at org.apache.jorphan.reflect.ClassFinder$ExtendsClassFilter.accept(ClassFinder.java:86) ~[jorphan.jar:5.4.3]

CodePudding user response:

Thanks everyone for your inputs.

I have resolved this issue by changing the client program to simple non spring boot application. After then, I placed the client program Jar into JMeter lib/ext directory and the dependent spring libraries to lib directory of JMeter. It worked now.

CodePudding user response:

The error says that JMeter cannot find BOOT-INF/classes/com/**/**/JmsSamplerClient class in JMeter Classpath so make sure to copy it there and restart JMeter to pick up the change.

Going forward be informed that:

  • lib/ext folder is for JMeter components and plugins
  • lib folder is for dependencies

so split your "jars" accordingly or put everything into an uber jar

Also given the nature of your custom sampler is that simple you could substitute it with JSR223 Sampler getting the same performance and removing overhead of compiling and copying custom sampler.

  • Related