Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caused by: com.jayway.jsonpath.PathNotFoundException: No results for path: $[0] #382

Closed
djangofan opened this issue Jul 21, 2020 · 13 comments
Assignees
Labels
enhancement known workaround Known workaround for this issue

Comments

@djangofan
Copy link

djangofan commented Jul 21, 2020

Problem:
When executing mvn jmeter:jmeter , I get the error:
Caused by: com.jayway.jsonpath.PathNotFoundException: No results for path: $[0]

  • Using Java 1.8 (same error with 1.11)
  • Error message is not consistent with my actual correct pom configuration.
  • Loading Jmeter 5.1.1 in pom
  • Created the most basic hello world .jmx file
  • Screenshot attached (showing additional information)
  • I am on Mac OSX
  • I don't think its the .jmx project file causing the issue since the error seems to be at the maven pom level.
  • I have years of experience with Jmeter 3.x but this is my first time trying 5.x
  • Yes, i ran mvn jmeter:configure before I tried to run mvn jmeter:jmeter
  • mvn jmeter:gui works fine

I believe this might be a bug because of the nature of the error message being similar to a null pointer.

jmeter_maven_plugin_err

@djangofan
Copy link
Author

djangofan commented Jul 21, 2020

More INFO: It works when I downgrade to jmeter-maven-plugin v.2.9.0 . 3.0.0 also doesn't work. 2.3.0 worked.

So, I have a workaround for now.

NOTE: unfortunately, because I need to use 2.9.0, the com.lazerycode.jmeter:jmeter-maven-plugin:remote-server does not work, having that issue where it cannot start because it is unable to locate the .jks file, regardless how I try to configure it. But, 3.1.1 works for the server. Maybe I can figure out a hack for a maven-profile to use 3.1.1 only on the server command.

@Ardesco
Copy link
Contributor

Ardesco commented Jul 22, 2020

Have you run mvn jmeter:configure before running mvn jmeter:jmeter

The configuration stage is not implicit any more, when you run mvn jmeter:jmeter it will try and parse your config.json to find an associated profile. If it can't find one you will get the above error and be asked to check your POM is configured correctly.

We need to put a bit more documentation around this and try and capture all of the edge cases, this FAQ entry is related.

https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/wiki/FAQ#how-to-i-execute-a-specific-configuration-from-the-command-line

@djangofan
Copy link
Author

djangofan commented Jul 22, 2020

As you can see in my screenshot, I DID that, UNLESS you are saying I am required to put the Jmeter plugin within a "profile" section, which I didn't do (as seen in screenshot). I put my jmeter plugin outside of a profile, just in the default build section. Seems to me that it should work either way right?

@Ardesco
Copy link
Contributor

Ardesco commented Jul 22, 2020

Right, I've had a look and refreshed my memory. You are hitting an edge case where we modified the code to try and catch the correct configuration for the majority of people.

Depending upon how you call a plugin, maven will give you differing execution ID's. You can configure these in your POM by setting an explicit execution ID e.g.

<executions>
    <execution>
        <id>configuration</id>
        <goals>
            <goal>configure</goal>
        </goals>
    </execution>
    <execution>
        <goals>
            <goal>jmeter</goal>
        </goals>
    </execution>
    <execution>
        <goals>
            <goal>results</goal>
        </goals>
    </execution>
</executions>

You can also ignore them and we will set default for you (Which is configuration) . Being able to set explicit execution IDs allows you to run tests with multiple JMeter configurations where you select a specific configuration like this:

<executions>
    <execution>
        <id>configuration-one</id>
        <goals>
            <goal>configure</goal>
        </goals>
        <configuration>
            <resultsFileFormat>xml</resultsFileFormat>
        </configuration>
    </execution>
    <execution>
        <id>configuration-two</id>
        <goals>
            <goal>configure</goal>
        </goals>
        <configuration>
            <resultsFileFormat>csv</resultsFileFormat>
        </configuration>
    </execution>
    <execution>
        <id>performance test one</id>
        <goals>
            <goal>jmeter</goal>
        </goals>
        <configuration>
            <selectedConfiguration>configuration-one</selectedConfiguration>
            <testFilesIncluded>
                <jMeterTestFile>test1.jmx</jMeterTestFile>
            </testFilesIncluded>
        </configuration>
    </execution>
    <execution>
        <id>performance test two</id>
        <goals>
            <goal>jmeter</goal>
        </goals>
        <configuration>
            <selectedConfiguration>configuration-two</selectedConfiguration>
            <testFilesIncluded>
                <jMeterTestFile>test2.jmx</jMeterTestFile>
            </testFilesIncluded>
        </configuration>
    </execution>
</executions>

There is however a gotcha with this solution, if you try to execute an explicit plugin goal through the command line, maven will assign this goal an execution ID of default-cli. This means that if you directly call mvn jmeter:configure instead of running mvn compile, it runs through the compile phase but sets a an execution ID of default-cli rather than configuration (Or whatever you have specified in your POM). This means that when you run mvn jmeter:jmeter we look for what we expect the default execution id to be (configuration) and we can't find it, so we throw the above error.

There are a couple of ways to fix this:

  • Call mvn compile instead of calling mvn jmeter:configure (This is how most people normally run the plugin anyway).
  • Call mvn jmeter:configure@configuration to set the correct execution ID for the compile stage.

We probably need to make this better. Currently we are always using either the default configuration value, or the value specified in <selectedConfiguration> and you can't override this on the command line when using mvn jmeter:jmeter (We should really specify a way to do this so that you can select the configuration you want to run when running mvn jmeter:jmeter.

Why didn't we modify mvn jmeter:configure to always use the default configuration value, or the value specified in <selectedConfiguration>?

That would break for people who want to use mvn jmeter:configure jmeter:gui since the gui goal sets a default execution ID of default-cli and we wanted to isolate the GUI configuration from your test run configuration.

@Ardesco Ardesco self-assigned this Jul 22, 2020
@Ardesco Ardesco added this to the 3.2.0 milestone Jul 22, 2020
@Ardesco
Copy link
Contributor

Ardesco commented Jul 22, 2020

Things to do:

  • Add support for setting the selectedConfiguration for the jmeter:jmeter goal on the command line
  • Enhance error message so that it asks you to check your Execution ID/Selected Configuration as well as asking if you have configured your POM correctly.
  • Maybe parse the config.json and suggest a correct configuration to select?
  • Maybe try using the default Execution ID of configuration and try an execution ID of default-cli if we can't find configuration (and log an appropriate Warning message).

@djangofan
Copy link
Author

djangofan commented Jul 23, 2020

Thank you. I got it working. If the documentation hadn't mentioned usage like mvn jmeter:configure jmeter:gui, then you are right, I probably would have just ran mvn verify and never noticed the above issue. :-( Thanks for unblocking me.

The problem was that my main requirement for using this plugin, was to be able to launch jmeter:gui . Since that is where I started reading the documentation, that is how I got tripped up.

@Ardesco Ardesco added the known workaround Known workaround for this issue label Jul 24, 2020
@toschder
Copy link

toschder commented Feb 8, 2021

Hi @djangofan and @Ardesco I ran into the same issue, using 3.3.0 version of the jmeter-maven-plugin.
I tried various configuration ways and I ended up with:

            <plugin>
                <groupId>com.lazerycode.jmeter</groupId>
                <artifactId>jmeter-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>configure</id>
                        <goals>
                            <goal>configure</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>jmeter-tests</id>
                        <goals>
                            <goal>jmeter</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>jmeter-check-results</id>
                        <goals>
                            <goal>results</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <selectedConfiguration>configure</selectedConfiguration>
                    <testFilesIncluded>
                        <jMeterTestFile>${testplan.name}.jmx</jMeterTestFile>
                    </testFilesIncluded>
...

Is this the only way to go, to get it working when executed by "mvn clean verify" ?

Will the documentation be updated, regarding this mandatory "selectedConfiguration" item, than?

@Ardesco
Copy link
Contributor

Ardesco commented Feb 8, 2021

mvn clean verify should work without specifying a selected configuration. You should only need a selectedConfiguration if you are trying to run mvn jmeter:jmeter

@toschder
Copy link

toschder commented Feb 8, 2021

Hi, thanx for this quick reply and yes it should - but it did not, that´s why I found this issue and the mentioned configuration option.
Without selectedConfiguration I got the path: $[0] Exception mentioned above.
Any ideas?

@Ardesco
Copy link
Contributor

Ardesco commented Feb 8, 2021

It's working fine locally for me:

└─[0] <> mvn clean verify
[INFO] Scanning for projects...
[INFO] 
[INFO] -------------< com.lazerycode.test:basic-integration-test >-------------
[INFO] Building basic-integration-test DEV-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ basic-integration-test ---
[INFO] Deleting /Users/fyre/Programming/OpenSource/jmeter-plugin-test/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ basic-integration-test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/fyre/Programming/OpenSource/jmeter-plugin-test/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ basic-integration-test ---
[INFO] No sources to compile
[INFO] 
[INFO] --- jmeter-maven-plugin:3.3.0:configure (configuration) @ basic-integration-test ---
[INFO]  
[INFO] -------------------------------------------------------
[INFO] C O N F I G U R I N G    J M E T E R
[INFO] -------------------------------------------------------
[INFO]  
[INFO] Building JMeter directory structure...
[INFO] Generating JSON Test config...
[INFO] Configuring JMeter artifacts...
[INFO] Populating JMeter directory...
[INFO] Copying extensions to /Users/fyre/Programming/OpenSource/jmeter-plugin-test/target/795b4f65-95ca-461e-b85e-1f3d22a879ed/jmeter/lib/ext 
Downloading dependencies: true
[INFO] Copying junit libraries to /Users/fyre/Programming/OpenSource/jmeter-plugin-test/target/795b4f65-95ca-461e-b85e-1f3d22a879ed/jmeter/lib/junit 
Downloading dependencies: true
[INFO] Copying test plan libraries to /Users/fyre/Programming/OpenSource/jmeter-plugin-test/target/795b4f65-95ca-461e-b85e-1f3d22a879ed/jmeter/lib 
Downloading dependencies: true
[INFO] Configuring JMeter properties...
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ basic-integration-test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/fyre/Programming/OpenSource/jmeter-plugin-test/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ basic-integration-test ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ basic-integration-test ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ basic-integration-test ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: /Users/fyre/Programming/OpenSource/jmeter-plugin-test/target/basic-integration-test-DEV-SNAPSHOT.jar
[INFO] 
[INFO] --- jmeter-maven-plugin:3.3.0:jmeter (jmeter-tests) @ basic-integration-test ---
[INFO]  
[INFO] -------------------------------------------------------
[INFO]  P E R F O R M A N C E    T E S T S
[INFO] -------------------------------------------------------
[INFO]  
[INFO] Executing test: dummy.jmx
[INFO] Arguments for forked JMeter JVM: [java, -Xms512M, -Xmx512M, -Djava.awt.headless=true, -jar, ApacheJMeter-5.4.1.jar, -d, /Users/fyre/Programming/OpenSource/jmeter-plugin-test/target/795b4f65-95ca-461e-b85e-1f3d22a879ed/jmeter, -j, /Users/fyre/Programming/OpenSource/jmeter-plugin-test/target/jmeter/logs/dummy.jmx.log, -l, /Users/fyre/Programming/OpenSource/jmeter-plugin-test/target/jmeter/results/20210208-dummy.csv, -n, -t, /Users/fyre/Programming/OpenSource/jmeter-plugin-test/target/jmeter/testFiles/dummy.jmx, -Dsun.net.http.allowRestrictedHeaders, true]
[INFO]  
[INFO] Creating summariser <summary>
[INFO] Created the tree successfully using /Users/fyre/Programming/OpenSource/jmeter-plugin-test/target/jmeter/testFiles/dummy.jmx
[INFO] Starting standalone test @ Mon Feb 08 11:36:07 GMT 2021 (1612784167548)
[INFO] Waiting for possible Shutdown/StopTestNow/HeapDump/ThreadDump message on port 4445
[INFO] Warning: Nashorn engine is planned to be removed from a future JDK release
[INFO] summary =      2 in 00:00:05 =    0.4/s Avg:   256 Min:   162 Max:   350 Err:     0 (0.00%)
[INFO] Tidying up ...    @ Mon Feb 08 11:36:12 GMT 2021 (1612784172980)
[INFO] ... end of run
[INFO] Completed Test: /Users/fyre/Programming/OpenSource/jmeter-plugin-test/target/jmeter/testFiles/dummy.jmx
[INFO]  
[INFO] 
[INFO] --- jmeter-maven-plugin:3.3.0:results (verify) @ basic-integration-test ---
[INFO]  
[INFO] -------------------------------------------------------
[INFO] S C A N N I N G    F O R    R E S U L T S
[INFO] -------------------------------------------------------
[INFO]  
[INFO] Will scan results using format: CSV
[INFO]  
[INFO] Parsing results file '/Users/fyre/Programming/OpenSource/jmeter-plugin-test/target/jmeter/results/20210208-dummy.csv' as type: CSV
[INFO] Number of failures in '20210208-dummy.csv': 0
[INFO] Number of successes in '20210208-dummy.csv': 8
[INFO]  
[INFO] -------------------------------------------------------
[INFO] P E R F O R M A N C E    T E S T    R E S U L T S
[INFO] -------------------------------------------------------
[INFO]  
[INFO] Result (.csv) files scanned: 1
[INFO] Successful requests:         8
[INFO] Failed requests:             0
[INFO] Failures:                    0.0% (0.0% accepted)
[INFO]  
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  8.797 s
[INFO] Finished at: 2021-02-08T11:36:13Z
[INFO] ------------------------------------------------------------------------
[INFO] Shutdown detected, destroying JMeter process...
[INFO]  

Using:

<build>
    <plugins>
        <plugin>
            <groupId>com.lazerycode.jmeter</groupId>
            <artifactId>jmeter-maven-plugin</artifactId>
            <version>3.3.0</version>
            <configuration>
                <testFilesIncluded>
                    <testFilesIncluded>dummy.jmx</testFilesIncluded>
                </testFilesIncluded>
            </configuration>
            <executions>
                <execution>
                    <id>configuration</id>
                    <goals>
                        <goal>configure</goal>
                    </goals>
                </execution>
                <execution>
                    <id>jmeter-tests</id>
                    <goals>
                        <goal>jmeter</goal>
                    </goals>
                </execution>
                <execution>
                    <id>verify</id>
                    <goals>
                        <goal>results</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

We also have an IT test using a basic config here:

https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/tree/master/src/it/basic-run

This also works as expected.

@toschder
Copy link

toschder commented Feb 8, 2021

Got it after cleaning my lenses:

                    <execution>
                        <id>configuration</id>     <== was "configure" before in my setup - just a typo :-(
                        <goals>
                            <goal>configure</goal>
                        </goals>
                    </execution>

@Ardesco
Copy link
Contributor

Ardesco commented Feb 8, 2021

Good to hear, I thought we may have some weird intermittent behaviour for a while.

@Ardesco
Copy link
Contributor

Ardesco commented Mar 30, 2021

Documentation updated to explain this in more detail:

https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/wiki/Basic-Configuration#running-on-the-command-line

We aren't going to parse the config.json and try and guess at a configuration you want to use as that's more likely to cause other issues.

@Ardesco Ardesco closed this as completed Mar 30, 2021
@Ardesco Ardesco removed this from the 3.6.0 milestone Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement known workaround Known workaround for this issue
Projects
None yet
Development

No branches or pull requests

3 participants