You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

JMeter 3.3与JMeter Maven插件2.6.0命令行执行故障求助

Hey there, let's tackle your two issues one by one—both are common pitfalls when upgrading JMeter and using the Maven plugin, so let's dive in:

Issue 1: HTTPS Connection Refused (HTTP works fine)

The fact that HTTP requests succeed but HTTPS ones fail tells me there's a key difference between how GUI and command-line/JMeter Maven plugin handle SSL or core dependencies. Here are the most impactful fixes:

Possible Causes & Fixes:

  1. Missing Required JMeter Dependencies
    Looking at your pom, you’ve excluded commons-math3:commons-math3—but JMeter 3.3 relies heavily on this library for core functionality, including SSL connection handling. When running via GUI, your local JMeter installation probably has this dependency already, but the Maven plugin builds an isolated classpath without it, breaking HTTPS connections.
  • Fix: Remove the <exclusion>commons-math3:commons-math3</exclusion> entry from your excludedArtifacts list.
  1. SSL Protocol Mismatch
    JMeter 3.3 updated default SSL protocols compared to the old 2.3 version. If your target server only supports older protocols (like TLSv1 instead of TLSv1.2), the command-line mode might fail while GUI works (if you manually adjusted settings there).
  • Fix: Add these lines to your jmeter.properties file:
    https.default.protocol=TLSv1.2
    https.socket.protocols=TLSv1,TLSv1.1,TLSv1.2
    
    Then, tell the Maven plugin to use this config by adding <jmeterPropertiesFile>path/to/your/jmeter.properties</jmeterPropertiesFile> inside the plugin’s <configuration> section.
  1. Un-Trusted SSL Certificates
    If your target uses a self-signed or internal CA certificate, the GUI might have cached the trust, but the command-line/Maven plugin doesn’t inherit this.
  • Fix: Import the certificate into JMeter’s truststore:
    keytool -import -alias your-server -file /path/to/cert.crt -keystore $JMETER_HOME/bin/cacerts -storepass changeit
    
    Then, ensure the Maven plugin uses this truststore by adding system properties to the plugin config:
    <systemProperties>
      <javax.net.ssl.trustStore>/path/to/your/jmeter/bin/cacerts</javax.net.ssl.trustStore>
      <javax.net.ssl.trustStorePassword>changeit</javax.net.ssl.trustStorePassword>
    </systemProperties>
    
  1. Firewall/Network Restrictions
    Sometimes command-line processes have stricter firewall rules than GUI apps. Test if you can reach the HTTPS port from the command line:
telnet your-hostname 443

If this fails, adjust your firewall to allow the Maven/JMeter process access to port 443.


Issue 2: Maven-Passed Parameters Not Working in JMeter

The users, duration, and other parameters not being picked up usually comes down to mismatched property names or conflicting dependencies. Let’s fix this:

Possible Causes & Fixes:

  1. Correct __P Function Usage
    In your pom, you map Maven’s ${Users} to JMeter’s users property via <users>${Users}</users>. In JMeter, the __P function requires a default value to avoid nulls if the property isn’t set.
  • Fix: In your JMeter test plan, use ${__P(users, 10)} (where 10 is your default number of users) instead of just ${__P(users)}. Apply the same pattern to other parameters:
    • Hostname: ${__P(host, default-host.com)}
    • Port: ${__P(port, 443)}
  1. Remove Manual JMeter Dependencies
    You’ve added ApacheJMeter_core and ApacheJMeter_java as direct dependencies, but the JMeter Maven plugin already manages these. This can cause version conflicts or classpath issues that break property passing.
  • Fix: Remove the entire <dependencies> section from your pom—let the plugin handle JMeter dependencies automatically.
  1. Verify Property Passing with Debug Logs
    To confirm if properties are reaching JMeter, run Maven with debug logging:
mvn verify -X -DUsers=50 -DhostName=your-server.com -DportNumber=443

Look for lines like Setting user property: users=50 in the logs. If you don’t see these, double-check your pom’s propertiesUser section is correctly nested inside <configuration>.

  1. UDV Configuration Fix
    If you’re using User Defined Variables (UDV), make sure you reference JMeter properties correctly. For example, set the UDV’s "users" variable value to ${__P(users, 10)}—don’t just type users or leave it blank.

Final Pom Adjustments Summary

Here’s a trimmed-down version of your pom with key fixes applied:

<modelVersion>4.0.0</modelVersion>
<groupId>com.abcd.efg</groupId>
<artifactId>app-Performance-Test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<build>
  <plugins>
    <plugin>
      <groupId>com.lazerycode.jmeter</groupId>
      <artifactId>jmeter-maven-plugin</artifactId>
      <version>2.6.0</version>
      <executions>
        <execution>
          <id>jmeter-tests</id>
          <phase>verify</phase>
          <goals>
            <goal>jmeter</goal>
          </goals>
        </execution>
      </executions>
      <configuration>
        <generateReports>true</generateReports>
        <scanResultsForSuccessfulRequests>true</scanResultsForSuccessfulRequests>
        <scanResultsForFailedRequests>true</scanResultsForFailedRequests>
        <downloadOptionalDependencies>false</downloadOptionalDependencies>
        <resultsDirectory>/path/report</resultsDirectory>
        <!-- Add SSL truststore config if needed -->
        <systemProperties>
          <javax.net.ssl.trustStore>/path/to/your/jmeter/bin/cacerts</javax.net.ssl.trustStore>
          <javax.net.ssl.trustStorePassword>changeit</javax.net.ssl.trustStorePassword>
        </systemProperties>
        <!-- Reference jmeter.properties with SSL settings -->
        <jmeterPropertiesFile>/path/to/your/jmeter.properties</jmeterPropertiesFile>
        <propertiesUser>
          <host>${hostName}</host>
          <port>${portNumber}</port>
          <users>${Users}</users>
          <duration>${duration}</duration>
          <rampup>${rampUp}</rampup>
          <datafile>${test.data}</datafile>
        </propertiesUser>
        <jmeterExtensions>
          <artifact>kg.apc:jmeter-plugins-casutg:2.4</artifact>
        </jmeterExtensions>
        <testResultsTimestamp>false</testResultsTimestamp>
        <excludedArtifacts>
          <!-- Removed commons-math3 exclusion -->
          <exclusion>commons-pool2:commons-pool2</exclusion>
          <exclusion>org.slf4j:slf4j-nop</exclusion>
          <exclusion>logkit:logkit</exclusion>
          <exclusion>avalon-logkit:avalon-logkit</exclusion>
          <exclusion>jdom:jdom</exclusion>
          <exclusion>log4j:log4j</exclusion>
          <exclusion>commons-logging:commons-logging</exclusion>
          <exclusion>excalibur-logger:excalibur-logger</exclusion>
        </excludedArtifacts>
      </configuration>
    </plugin>
  </plugins>
</build>

Try these steps one by one—start with fixing dependencies and property references, as those are the most likely culprits. If you still run into issues, share the debug logs from Maven and we can dig deeper!

内容的提问来源于stack exchange,提问作者user1480332

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 08:49:47