JMeter: NoClassDefFoundError error when used jackson jar - java

I'm creating a custom Java sampler in JMeter. It's working just fine. However, when I wanted it to return a result in JSON, JMeter didn't found the .jar for the jackson-databind library, which is needed for the creation of the JSON.
I put it to the /lib/ext folder in the JMeter main directory. I also copied to /lib, to no avail. (I know that /lib/ext shouldn't be used for dependency jars, but JMeter doesn't find my utility jars in /lib in my experience.)
I tried adding the path to the variables search_paths, user.classpath and plugin_dependency_paths in jmeter.properties. I tried with absolute path, relative path, with slash, with backslash, but neither helped.
I tried setting the JMETER_HOME variable to the address of my installation. It worked, yet it didn't help.
I tried running in two environments. The first is within Eclipse (I copied JMeter to a workspace folder, then imported the project), with JMeter 4.0. I got this error in the log:
java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ObjectMapper
at (creating ObjectMapper here)
at (creating ResponseJSON here)
at org.apache.jmeter.protocol.java.sampler.JavaSampler.sample(JavaSampler.java:197) ~[ApacheJMeter_java.jar:4.0 r1823414]
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:490) ~[ApacheJMeter_core.jar:4.0 r1823414]
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:416) ~[ApacheJMeter_core.jar:4.0 r1823414]
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:250) ~[ApacheJMeter_core.jar:4.0 r1823414]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_101]
I also ran JMeter 3.3 from the .bat file, adding the jars to the same place. I got this error on the console:
Unknown error checking for existence of class: com.fasterxml.jackson.databind.ObjectMapper
java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/Versioned
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.logging.log4j.util.LoaderUtil.loadClass(LoaderUtil.java:141)
at org.apache.logging.log4j.util.LoaderUtil.isClassAvailable(LoaderUtil.java:115)
at org.apache.logging.log4j.core.util.Loader.isClassAvailable(Loader.java:310)
at org.apache.logging.log4j.core.config.yaml.YamlConfigurationFactory.<init>(YamlConfigurationFactory.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.apache.logging.log4j.core.util.ReflectionUtil.instantiate(ReflectionUtil.java:188)
at org.apache.logging.log4j.core.config.ConfigurationFactory.addFactory(ConfigurationFactory.java:190)
at org.apache.logging.log4j.core.config.ConfigurationFactory.getInstance(ConfigurationFactory.java:164)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:613)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:634)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:229)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:152)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:122)
at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)
at org.apache.jmeter.JMeter.<clinit>(JMeter.java:109)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.apache.jmeter.NewDriver.main(NewDriver.java:246)
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.core.Versioned
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 43 more
I didn't try to debug the classloader, but probably that'll be the next step when I finished posting it here.
I have this version of the file, same as in my POM:
https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind/2.9.4

Part of jackson-databind dependencies is specifically jackson-core jar you are probably missing and include missing class in your error: com.fasterxml.jackson.core.Versioned
See Jackson Installation:
The three JAR files (projects) in the Jackson JSON API are:
Jackson Core
Jackson Annotations
Jackson Databind

Related

jmeter class not found

I am trying to run apache jmeter on my VM but getting this error.
D:\Users\1255592\Desktop\apache-jmeter-3.1\apache-jmeter-3.1\bin>jmeter
java.lang.NoClassDefFoundError: com/thoughtworks/xstream/converters/ConversionException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.apache.jmeter.NewDriver.main(NewDriver.java:257)
Caused by: java.lang.ClassNotFoundException: com.thoughtworks.xstream.converters.ConversionException
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 5 more
JMeter home directory was detected as:
D:\Users\1255592\Desktop\apache-jmeter-3.1\apache-jmeter-3.1
I am using java 1.7
Your installation of JMeter is corrupt as the message here tells you that a class of xstream which is embedded as part of jmeter in lib folder is missing.
com.thoughtworks.xstream.converters.ConversionException
So reinstall your version and ensure you unzip in a folder that you own.

Jar file execution issue?

I am using this command to run my jar file
java -cp otpreq.jar com.otp.req.SendRequest
and its giving error-:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/httpclient/methods/RequestEntity
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.methods.RequestEntity
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
Why this error is coming I can't figure out .
I checked the Library and org/apache/commons/httpclient/methods/RequestEntity is a Interface.
Assuming you have the http-client.jar:
java -cp otpreq.jar:http-client.jar com.otp.req.SendRequest
If O.S is windows, replace : by ;
Note: the newest httpclient is not located at apache commons, but at apache http components
You have to include all the supporting jars in class path (command line itself).
Or bind all your supporting jars inside otpreq.jar.
Either one of these will solve this issue.

Executing jar file throws class not found error

Using Eclipse, I am modifying a Java project we have been using for years. a specific class method is typically executed by sending a message through IBM WebSphere MQ. However, I now have a need to develop some new functionality and I need to be able to test it out side the MQ world.
I am able to successfully debug the application in Eclipse, but if I attempt to execute the jar file from a command prompt I receive the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: XMLBuilder/Node
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: XMLBuilder.Node
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 6 more
My build is done using an ant script. This does not include a Class-Path attribute when creating the manifest.
The XMLBuilder.jar file is included in the target jar. Running jar -tf file.jar shows
META-INF/)
META-INF/MANIFEST.MF)
... Omitted for Brevity ...
XMLBuilder.jar
What might I be missing?
Thank you

Java - JOGL deploy: NoClassDefFoundError

Dev env: ItelliJ 14 -> compiles and runs fine.
When executing my custom created .jar from command line this appears
C:\Java\Projects\OpenGLES\out\artifacts\Test1>java -jar Test1.jar
Exception in thread "main" java.lang.NoClassDefFoundError: com/jogamp/opengl/G
ventListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.jogamp.opengl.GLEventListener
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 13 more
I'm trying to create .jar artifact, that I could just double click start.
I think that the problem means that this class cannot find some resources. The JOGL/JogAmp official sites gives explanation on deployment of .jars with JOGL, but I think that I missed something.
The Test1.jar has following structure:
Test1.jar/
--com/
----company/
------Main.class
--jar/
----gluegen-rt.jar
----gluegen-rt-natives-windows-amd64.jar
----gluegen-rt-natives-windows-i586.jar
----jogl-all.jar
----jogl-all-natives-windows-amd64.jar
----jogl-all-natives-windows-i586.jar
--lib/
----windows-amd64/
-------gluegen-rt.dll
-------joal.dll
-------jocl.dll
-------jogl_cg.dll
-------jogl_deskop.dll
-------jogl_mobile.dll
-------nativewindow_awt.dll
-------nativewindow_win32.dll
-------newt.dll
-------soft_oal.dll
--META-INF/
----MANIFEST.MF
--com
--jar
--lib
--META-INF
manifest.mf contains -
Manifest-Version: 1.0
Main-Class: com.company.Main
By the stack trace it seems that the JVM cannot find the class com.jogamp.opengl.GLEventListener that means it can't resolve the path to the included jar files. The path of the jar files is not correct. Follow the link to see how to package jars correctly.
https://docs.oracle.com/javase/tutorial/deployment/jar/

java , eclipse jar problem

i'm kind of new to java. I use eclipse and i imported some jar files with some classes by going to properties -> Add External Jars;
The problem is that when i try to use a class from the jar i get the following exception:
Exception in thread "main" java.lang.NoClassDefFoundError: nextapp/echo2/app/event/ActionListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at Program.main(Program.java:12)
Caused by: java.lang.ClassNotFoundException: nextapp.echo2.app.event.ActionListener
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 13 more
The class is supposed to create a window,
i guess that the jar has to import somehow other stuff or something like that,
How can i fix this?
PS. Sorry for the bad code , i don't know tags here.
thansk,
Raxvan
Most jars you download will include 0-5 other jars that are needed. They all need included in order to use the jar. Very quickly you end up with 20 jars in a simple 1000 line Java project, but thems are the breaks.
Look inside your downloaded jar zip. Should be a lib directory or such with all the libs you need.
Another way to get around this would be to use a tool like Ivy or Maven to manage downloading dependencies. Depending on what libraries you are using, you may have many transitive dependencies, and doing that all by hand will end up taking a lot of time.

Categories