tuanhiep / mqttjmeter

This is the plugin for Jmeter to Test MQTT protocol
Apache License 2.0
86 stars 56 forks source link

Exception java.lang.NoClassDefFoundError when using MQTT tests #12

Open matheus-fonseca opened 9 years ago

matheus-fonseca commented 9 years ago

I'm trying to make a MQTT test (pub/sub) but Jmeter gives me this Exception:

2015/05/29 11:21:33 ERROR - jmeter.threads.JMeterThread: Test failed! java.lang.NoClassDefFoundError: org/fusesource/mqtt/client/Callback
    at org.apache.jmeter.protocol.mqtt.sampler.SubscriberSampler.threadStarted(SubscriberSampler.java:221)
    at org.apache.jmeter.threads.JMeterThread$ThreadListenerTraverser.addNode(JMeterThread.java:610)
    at org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:998)
    at org.apache.jorphan.collections.HashTree.traverse(HashTree.java:980)
    at org.apache.jmeter.threads.JMeterThread.threadStarted(JMeterThread.java:579)
    at org.apache.jmeter.threads.JMeterThread.initRun(JMeterThread.java:567)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:257)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.fusesource.mqtt.client.Callback
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 8 more

2015/05/29 11:21:33 INFO  - jmeter.threads.JMeterThread: Thread finished: Grupo de Usuários 1-1 
2015/05/29 11:21:33 ERROR - jmeter.JMeter: Uncaught exception:  java.lang.NoClassDefFoundError: org/fusesource/mqtt/client/Listener
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at org.apache.jmeter.protocol.mqtt.sampler.SubscriberSampler.threadFinished(SubscriberSampler.java:282)
    at org.apache.jmeter.threads.JMeterThread$ThreadListenerTraverser.addNode(JMeterThread.java:612)
    at org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:998)
    at org.apache.jorphan.collections.HashTree.traverse(HashTree.java:980)
    at org.apache.jmeter.threads.JMeterThread.threadFinished(JMeterThread.java:584)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:315)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.fusesource.mqtt.client.Listener
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 18 more

2015/05/29 11:21:33 INFO  - jmeter.engine.StandardJMeterEngine: Notifying test listeners of end of test 
2015/05/29 11:21:33 ERROR - jmeter.JMeter: Uncaught exception:  java.lang.NoClassDefFoundError: org/apache/jmeter/protocol/mqtt/client/ListenerforSubscribe
    at org.apache.jmeter.protocol.mqtt.sampler.SubscriberSampler.testEnded(SubscriberSampler.java:179)
    at org.apache.jmeter.engine.StandardJMeterEngine.notifyTestListenersOfEnd(StandardJMeterEngine.java:226)
    at org.apache.jmeter.engine.StandardJMeterEngine.run(StandardJMeterEngine.java:448)
    at java.lang.Thread.run(Thread.java:745)

I followed your installation instructions at README.

hemikak commented 9 years ago

This is because fusesource library files are not getting included in the mqtt plugin jar. Add the pom file fix mentioned in https://github.com/tuanhiep/mqtt-jmeter/pull/1/files and see.

andreibosco commented 9 years ago

I've tried using the fixed pom file and now I can't build the project: [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.304 s [INFO] Finished at: 2015-06-13T14:15:36-03:00 [INFO] Final Memory: 18M/45M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.0:shade (default) on project mqtt-jmeter: Execution default of goal org.apache.maven.plugins:maven-shade-plugin:2.0:shade failed: A required class was missing while executing org.apache.maven.plugins:maven-shade-plugin:2.0:shade: org/sonatype/aether/version/VersionConstraint [ERROR] -----------------------------------------------------

hemikak commented 9 years ago

Hi @andreibosco ,

What is the maven version you are using ? I am using 3.0.5.

andreibosco commented 9 years ago

I'm using 3.3.3. I've just changed maven-shade-plugin from 2.0 to 2.1 and now it builds fine.

firesh-bakhda commented 9 years ago

You will need to build JMeter with dependencies. Add the following to the POM.xml

        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>

            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>

            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

Add this to the tag.

Secondly, make sure your JMeter version complies to the JMeter version you are using.

2.13

Third, change the mqtt-client library version to 1.10 instead of 1.4 (Thou i think both are working as what i tried)

    <dependency>
      <groupId>org.fusesource.mqtt-client</groupId>
      <artifactId>mqtt-client</artifactId>
      <version>1.10</version>
    </dependency>

By doing this you eliminate all the FutureListener exceptions, input string "" errors and so on. 1) Publisher: Input string "" errors are becoz of Suffix Length is empty on the UI, so make sure you have value

2) Subscriber: Input string "" errors are becoz of Timeout is empty, make sure put a timeout there

Full Sample pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>fr.liglab.erods.jmeter.mqtt</groupId>
<artifactId>mqtt-jmeter</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Apache JMeter :: MQTT Injector</name>
<description>MQTT Injector for Apache JMeter</description>

<properties>
    <jmeter-version>2.13</jmeter-version>
</properties>

<dependencies>

    <dependency>
        <groupId>org.apache.jmeter</groupId>
        <artifactId>ApacheJMeter_core</artifactId>
        <version>${jmeter-version}</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.jmeter</groupId>
        <artifactId>ApacheJMeter_java</artifactId>
        <version>${jmeter-version}</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.fusesource.mqtt-client</groupId>
      <artifactId>mqtt-client</artifactId>
      <version>1.10</version>
    </dependency>

</dependencies>

<build>
    <finalName>${project.artifactId}</finalName>
    <defaultGoal>install</defaultGoal>
    <plugins>

        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>

            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>

            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>

    </plugins>
</build>

Current remaining issues that i still see :

1) Publisher : Client ID value on UI is not retained. 2) Publisher & Subscriber : Suffix Length Values are not retained 3) Subscriber : Keeps saying Received 0 messages thou there is something published.

@tuanhiep - Do have a look and see if i make any sense to ease your understanding.