我正在为我的Jmeter运行生成仪表板。执行是通过jmeter-maven-plugin完成的。
我的POM中的关键插件如下。
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.0.3</version>
<configuration>
<testFilesDirectory>src/test/jmeter/TestPlans</testFilesDirectory>
<!-- <postTestPauseInSeconds>10</postTestPauseInSeconds> -->
<testResultsTimestamp>false</testResultsTimestamp>
<overrideRootLogLevel>DEBUG</overrideRootLogLevel>
<suppressJMeterOutput>false</suppressJMeterOutput>
<ignoreResultFailures>true</ignoreResultFailures>
<resultsFileFormat>xml</resultsFileFormat>
<propertiesJMeter>
<jmeter.save.saveservice.thread_counts>true</jmeter.save.saveservice.thread_counts>
</propertiesJMeter>
<jmeterPlugins>
<plugin>
<groupId>kg.apc</groupId>
<artifactId>jmeter-plugins</artifactId>
</plugin>
</jmeterPlugins>
<jmeterExtensions>
<artifact>kg.apc:jmeter-plugins-standard:jar:1.4.0</artifact>
<artifact>kg.apc:jmeter-plugins-extras:jar:1.3.0</artifact>
<artifact>kg.apc:jmeter-plugins-redis:jar:0.1</artifact>
</jmeterExtensions>
</configuration>
<executions>
<execution>
<id>execute-jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
<phase>integration-test</phase>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>kg.apc</groupId>
<artifactId>jmeter-plugins</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion>
<groupId>kg.apc</groupId>
<artifactId>perfmon</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.jmeter</groupId>
<artifactId>jorphan</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.bsf</groupId>
<artifactId>bsf-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcmail-jdk15</artifactId>
</exclusion>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15</artifactId>
</exclusion>
<exclusion>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>verify</phase>
<configuration>
<tasks>
<mkdir dir="${basedir}/target/jmeter/results/dashboard" />
<copy file="${basedir}/src/test/resources/reportgenerator.properties" tofile="${basedir}/target/jmeter/bin/reportgenerator.properties" />
<copy todir="${basedir}/target/jmeter/bin/report-template">
<fileset dir="${basedir}/src/test/resources/report-template" />
</copy>
<java jar="${basedir}/target/jmeter/bin/ApacheJMeter-3.0.jar" fork="true">
<arg value="-g" />
<arg value="${basedir}/target/jmeter/results/*.jtl" />
<arg value="-o" />
<arg value="${basedir}/target/jmeter/results/dashboard/" />
</java>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
执行失败,出现以下错误。
当尝试手动执行命令时,会看到以下日志。
C:\Program Files\Java> jdk1.8.0_112\bin\java -jar C:\Users\testing\automation\jmeter_regression\target\jmeter\bin\ApacheJMeter-3.0.jar -g C:\Users\testing\automation\jmeter_regression/target/jmeter/results/CSS_Regression.jtl -o C:\Users\testing\automation\jmeter_regression/target/jmeter/results/dashboard/
log_file=jmeter.log java.io.FileNotFoundException: jmeter.log (Access is denied)
[log_file-> System.out]
2017/02/28 16:49:51 INFO - jmeter.util.JMeterUtils: Setting Locale to en_AU
2017/02/28 16:49:51 INFO - jmeter.JMeter: Loading system properties from: C:\Users\testing\automation\jmeter_regression\target\jmeter\bin\system.properties
2017/02/28 16:49:51 INFO - jmeter.JMeter: Copyright (c) 1998-2016 The Apache Software Foundation
2017/02/28 16:49:51 INFO - jmeter.JMeter: Version 3.0 r1743807
2017/02/28 16:49:51 INFO - jmeter.JMeter: java.version=1.8.0_112
2017/02/28 16:49:51 INFO - jmeter.JMeter: java.vm.name=Java HotSpot(TM) 64-Bit Server VM
2017/02/28 16:49:51 INFO - jmeter.JMeter: os.name=Windows 7
2017/02/28 16:49:51 INFO - jmeter.JMeter: os.arch=amd64
2017/02/28 16:49:51 INFO - jmeter.JMeter: os.version=6.1
2017/02/28 16:49:51 INFO - jmeter.JMeter: file.encoding=Cp1252
2017/02/28 16:49:51 INFO - jmeter.JMeter: Max memory =2835349504
2017/02/28 16:49:51 INFO - jmeter.JMeter: Available Processors =4
2017/02/28 16:49:51 INFO - jmeter.JMeter: Default Locale=English (Australia)
2017/02/28 16:49:51 INFO - jmeter.JMeter: JMeter Locale=English (Australia)
2017/02/28 16:49:51 INFO - jmeter.JMeter: JMeterHome=C:\Users\testing\automation\jmeter_regression\target\jmeter
2017/02/28 16:49:51 INFO - jmeter.JMeter: user.dir =C:\Program Files\Java
2017/02/28 16:49:51 INFO - jmeter.JMeter: PWD =C:\Program Files\Java
2017/02/28 16:49:51 FATAL - jmeter.JMeter: An error occurred: java.lang.NoSuchMethodError: org.apache.jorphan.util.JOrphanUtils.canSafelyWriteToFolder(Ljava/io/File;)V
at org.apache.jmeter.JMeter.extractAndSetReportOutputFolder(JMeter.java:530)
at org.apache.jmeter.JMeter.start(JMeter.java:476)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.jmeter.NewDriver.main(NewDriver.java:259)
An error occurred: org.apache.jorphan.util.JOrphanUtils.canSafelyWriteToFolder(Ljava/io/File;)V
C:\Program Files\Java>
我在jars could not be resolved for apache jmter 2.13 with maven中尝试了解决方案。但似乎并没有奏效。我想我没有正确配置pom。
我应该在这做什么?
答案 0 :(得分:0)
原因是以下扩展名之一的版本。
<artifact>kg.apc:jmeter-plugins-standard:jar:1.4.0</artifact>
<artifact>kg.apc:jmeter-plugins-extras:jar:1.3.0</artifact>
<artifact>kg.apc:jmeter-plugins-redis:jar:0.1</artifact>
其中一个复制2.x版本的jorphan.jar,其中没有引入方法canSafelyWriteToFolder(Ljava / io / File)。
我将它们更新为最新版本,如下所示
<artifact>kg.apc:jmeter-plugins-standard:jar:1.4.0</artifact>
<artifact>kg.apc:jmeter-plugins-extras:jar:1.4.0</artifact>
<artifact>kg.apc:jmeter-plugins-redis:jar:0.2</artifact>
将jorphan-3.0.jar复制到jemeter lib。