katebl58
katebl58

Reputation: 143

Maven+jmeter not recognizing json path extractor

I have a jmx file which has JSON path extractor which parses the JSON response of one of the requests. This test plan works perfectly fine when I run it in GUI mode. But the same does not run fine when I run it through maven using lazerycode plugin. I have added the dependency in POM.xml as:

        <dependency>
            <groupId>kg.apc</groupId>
            <artifactId>jmeter-plugins-extras-libs</artifactId>
            <version>1.3.0</version>
</dependency>
<dependency>
            <groupId>kg.apc</groupId>
            <artifactId>jmeter-plugins</artifactId>
            <version>1.0.0</version><!-- old:1.0.0 -->
            <exclusions>
                <exclusion>
                    <groupId>kg.apc</groupId>
                    <artifactId>perfmon</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.jmeter</groupId>
                    <artifactId>jorphan</artifactId>
                </exclusion> 
                <exclusion>
                    <groupId>org.apache.hbase</groupId>
                    <artifactId>hbase</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.hadoop</groupId>
                    <artifactId>hadoop-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

and the Jmeterplugins is:

<jmeterPlugins>                 
 <plugin>
 <groupId>kg.apc</groupId>
 <artifactId>jmeter-plugins-extras-libs</artifactId>
 </plugin>
<plugin>
<groupId>kg.apc</groupId>
<artifactId>jmeter-plugins</artifactId>
</plugin>

But I am getting the following error while running the maven as: mvn clean verify

     [info] Error in NonGUIDriver java.lang.IllegalArgumentException: Problem loading
 XML from:'C:\Users\user1\workspace\loadtest\loadTestModule\src\test
\jmeter\testscript.jmx', conversion error com.thoughtworks.xst
ream.converters.ConversionException: com.atlantbh.jmeter.plugins.jsonutils.jsonp
athextractor.JSONPathExtractor : com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor

I can see the JSONPathExtractorGui.class in the jmeter-plugins-1.0.0.jar under com/atlantbh/jmeter/plugins/jsonutils/jsonpathextractor/gui.

Jmx has the following lines for JSON path extracting logic:

<hashTree/>
      <com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor guiclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.gui.JSONPathExtractorGui" testclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor" testname="jp@gc - JSON Path Extractor" enabled="true">
        <stringProp name="TestPlan.comments">$..url[*]</stringProp>
        <stringProp name="VAR">url</stringProp>
        <stringProp name="JSONPATH">$..url[*]</stringProp>
        <stringProp name="DEFAULT"></stringProp>
        <stringProp name="VARIABLE"></stringProp>
        <stringProp name="SUBJECT">BODY</stringProp>
      </com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor>
      <hashTree/>

What's the resolution for this problem?

Upvotes: 2

Views: 1565

Answers (2)

Binod Adhikary
Binod Adhikary

Reputation: 76

I was also getting the exact same error. Finally, it was fixed after following this:
https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/wiki/Adding%20Additional%20Libraries%20To%20The%20Classpath#adding-jars-to-the-libext-directory
(Read the section: Adding jar's to the /lib/ext directory)

What I did was:
1. Add plugin jmeter-plugins-extras-libs inside "configuration" inside "execution" of jmeter-maven-plugin.
2. Add the dependency jmeter-plugins-extras-libs just outside "executions", inside "dependencies"

Here is the relevant section from my pom:

   ...
   <plugin>
        <groupId>com.lazerycode.jmeter</groupId>
        <artifactId>jmeter-maven-plugin</artifactId>
        <version>1.10.1</version>
        <executions>
          <execution>
            <id>jmeter-tests</id>
            <phase>verify</phase>
            <goals>
              <goal>jmeter</goal>
            </goals>
            <configuration>
              <jmeterPlugins>
                <plugin>
                  <groupId>kg.apc</groupId>
                  <artifactId>jmeter-plugins-extras-libs</artifactId>
                </plugin>
              </jmeterPlugins>

              <testResultsTimestamp>false</testResultsTimestamp>
              <showthroughput>true</showthroughput>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>kg.apc</groupId>
            <artifactId>jmeter-plugins-extras-libs</artifactId>
            <version>1.3.1</version>
          </dependency>
        </dependencies>
      ...

And it worked. I didn't add jmeter-plugins, and was not required. I hope it would work for you, if it hasn't already.

Upvotes: 4

RaGe
RaGe

Reputation: 23677

You might have to add other jmeter plugins as well:

<jmeterPlugins>
<plugin>
  <groupId>kg.apc</groupId>
  <artifactId>jmeter-plugins-common</artifactId>
</plugin>
<plugin>
  <groupId>kg.apc</groupId>
  <artifactId>jmeter-plugins-standard</artifactId>
</plugin>
<plugin>
  <groupId>kg.apc</groupId>
  <artifactId>jmeter-plugins-extras</artifactId>
</plugin>
<plugin>
  <groupId>kg.apc</groupId>
  <artifactId>jmeter-plugins-extras-libs</artifactId>
</plugin>
</jmeterPlugins>

Upvotes: 1

Related Questions