简而言之,如果我从Maven下面运行JMeter计划测试,它会给出结果:
javax.naming.NamingException: javax.naming.NoInitialContextException: Cannot instantiate class: org.apache.activemq.jndi.ActiveMQInitialContextFactory [Root exception is java.lang.ClassNotFoundException: org.apache.activemq.jndi.ActiveMQInitialContextFactory]
然而,如果我在没有maven插件的情况下运行相同的JMeter计划测试,它会正确运行。
提供更多详情:
如果我以这种方式启动ActiveMQ(Windows命令提示符):
cd C:\_d\server\ActiveMQ\apache-activemq-5.9.0\bin
activemq.bat
然后,我运行完全相同的jmx脚本:
jmeter.bat -n -t C:\_d\scripts\JMeter\JMS_SQS_MVN\SQS.jmx -l C:\temp\activemq.jtl -j C:\temp\activemq.jmx.log
我可以转到ActiveMq控制台,看看在这样的jmx脚本中出现的标记为sqs_dummy_mvn6的队列。
现在,通过maven插件获取相同的脚本,它只显示“无法实例化类:org.apache.activemq.jndi.ActiveMQInitialContextFactory”。好吧,据我所知,每当我使用jmeter-maven-plugin时,嵌入式jmeter和嵌入式activemq都会在验证阶段启动和停止。
我通过maven这样调用相同的脚本:
mvn clean verify
... \ artproducer \ src \ test \ jmeter \ SQS.jmx(仅在发布者下方启用;禁用订阅以使测试更简单)
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="2.9" jmeter="3.0 r1743807">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Plano de Teste SQS" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="Variáveis Definidas Pelo Usuário" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="TestPlan.user_define_classpath"></stringProp>
</TestPlan>
<hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Grupo de Usuários - Consumers" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Controlador de Iteração" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">1</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">1</stringProp>
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
<longProp name="ThreadGroup.start_time">1484067293000</longProp>
<longProp name="ThreadGroup.end_time">1484067293000</longProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
</ThreadGroup>
<hashTree>
<SubscriberSampler guiclass="JMSSubscriberGui" testclass="SubscriberSampler" testname="JMS Subscriber" enabled="false">
<stringProp name="jms.jndi_properties">false</stringProp>
<stringProp name="jms.initial_context_factory">org.apache.activemq.jndi.ActiveMQInitialContextFactory</stringProp>
<stringProp name="jms.provider_url">tcp://localhost:61616</stringProp>
<stringProp name="jms.connection_factory">ConnectionFactory</stringProp>
<stringProp name="jms.topic">dynamicQueues/sqs_dummy_mvn6</stringProp>
<stringProp name="jms.security_principle"></stringProp>
<stringProp name="jms.security_credentials"></stringProp>
<boolProp name="jms.authenticate">false</boolProp>
<stringProp name="jms.iterations">1</stringProp>
<stringProp name="jms.read_response">true</stringProp>
<stringProp name="jms.client_choice">jms_subscriber_on_message</stringProp>
<boolProp name="jms.stop_between_samples">true</boolProp>
<stringProp name="jms.timeout">60000</stringProp>
<boolProp name="jms.destination_static">false</boolProp>
</SubscriberSampler>
<hashTree>
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="false">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<threadCounts>true</threadCounts>
<idleTime>true</idleTime>
</value>
</objProp>
<stringProp name="filename"></stringProp>
</ResultCollector>
<hashTree/>
</hashTree>
<ResultCollector guiclass="GraphVisualizer" testclass="ResultCollector" testname="Graph Results" enabled="false">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<threadCounts>true</threadCounts>
<idleTime>true</idleTime>
</value>
</objProp>
<stringProp name="filename"></stringProp>
</ResultCollector>
<hashTree/>
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="false">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<threadCounts>true</threadCounts>
<idleTime>true</idleTime>
</value>
</objProp>
<stringProp name="filename"></stringProp>
</ResultCollector>
<hashTree/>
<PublisherSampler guiclass="JMSPublisherGui" testclass="PublisherSampler" testname="JMS Publisher" enabled="true">
<stringProp name="jms.jndi_properties">false</stringProp>
<stringProp name="jms.initial_context_factory">org.apache.activemq.jndi.ActiveMQInitialContextFactory</stringProp>
<stringProp name="jms.provider_url">tcp://localhost:61616</stringProp>
<stringProp name="jms.connection_factory">ConnectionFactory</stringProp>
<stringProp name="jms.topic">dynamicQueues/sqs_dummy_mvn6</stringProp>
<stringProp name="jms.expiration"></stringProp>
<stringProp name="jms.priority"></stringProp>
<stringProp name="jms.security_principle"></stringProp>
<stringProp name="jms.security_credentials"></stringProp>
<stringProp name="jms.text_message">testando a partir do JMeter4444</stringProp>
<stringProp name="jms.input_file"></stringProp>
<stringProp name="jms.random_path"></stringProp>
<stringProp name="jms.config_choice">jms_use_text</stringProp>
<stringProp name="jms.config_msg_type">jms_text_message</stringProp>
<stringProp name="jms.iterations">1</stringProp>
<boolProp name="jms.authenticate">false</boolProp>
<elementProp name="jms.jmsProperties" elementType="JMSProperties">
<collectionProp name="JMSProperties.properties"/>
</elementProp>
<boolProp name="jms.destination_static">false</boolProp>
</PublisherSampler>
<hashTree>
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="false">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<threadCounts>true</threadCounts>
<idleTime>true</idleTime>
</value>
</objProp>
<stringProp name="filename"></stringProp>
</ResultCollector>
<hashTree/>
</hashTree>
</hashTree>
</hashTree>
</hashTree>
</jmeterTestPlan>
... \ artproducer \目标\ JMeter的\导致\ 20170111-SQS.jtl
<?xml version="1.0" encoding="UTF-8"?>
<testResults version="1.2">
<sample t="0" it="0" lt="0" ts="0" s="false" lb="JMS Publisher" rc="000" rm="javax.naming.NamingException: javax.naming.NoInitialContextException: Cannot instantiate class: org.apache.activemq.jndi.ActiveMQInitialContextFactory [Root exception is java.lang.ClassNotFoundException: org.apache.activemq.jndi.ActiveMQInitialContextFactory]" tn="Grupo de Usuários - Consumers 1-1" dt="" by="0" ng="1" na="1"/>
</testResults>
POM:
<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>grpactivemq</groupId>
<artifactId>artproducer</artifactId>
<!-- <packaging>pom</packaging> -->
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>artproducer Maven Webapp</name>
<url>http://maven.apache.org</url>
<!-- enviando queue para o broker do ActiveMq iniciado como serviço -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdk.version>1.8</jdk.version>
<junit.version>4.11</junit.version>
<activemq.version>5.9.0</activemq.version>
<spring.version>4.1.5.RELEASE</spring.version>
</properties>
<dependencies>
<!-- activemq -->
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
<version>${activemq.version}</version>
</dependency>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- xbean -->
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-spring</artifactId>
<version>3.7</version>
</dependency>
<!-- junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<!-- <scope>test</scope> -->
</dependency>
</dependencies>
<build>
<plugins>
<!-- <plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<executions>
<execution>
<id>Run load Test</id>
<phase>generate-sources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${basedir}/scripts/jmeter_exe.sh</executable>
</configuration>
</execution>
</executions>
</plugin> -->
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.0.3</version>
<executions>
<execution>
<id>jmeter-test</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
<version>${activemq.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
</plugins>
<finalName>artproducer</finalName>
</build>
</project>
答案 0 :(得分:4)
我认为您需要将activemq-all.jar
依赖项添加到JMeter的/lib/ext
文件夹,如here所述,其语法与您使用的<dependency>
略有不同:
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.0.3</version>
<executions>
<execution>
<id>jmeter-test</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<jmeterExtensions>
<artifact>org.apache.activemq:activemq-all:jar:${activemq.version}</artifact>
</jmeterExtensions>
</configuration>
</plugin>
答案 1 :(得分:0)
使用plugin
的2.6.0版在配置节点下添加:
C:\WINDOWS\system32>npm uninstall chromedriver
- pify@2.3.0 node_modules\globby\node_modules\pify
- globby@6.1.0 node_modules\globby
- isarray@1.0.0 node_modules\isarray
- minimist@0.0.8 node_modules\minimist
- mkdirp@0.5.0 node_modules\extract-zip\node_modules\mkdirp
- ms@2.0.0 node_modules\ms
- debug@2.6.9 node_modules\debug
- p-map@1.2.0 node_modules\p-map
- pend@1.2.0 node_modules\pend
- fd-slicer@1.0.1 node_modules\fd-slicer
- pify@3.0.0 node_modules\pify
- process-nextick-args@1.0.7 node_modules\process-nextick-args
- string_decoder@1.0.3 node_modules\string_decoder
- typedarray@0.0.6 node_modules\typedarray
- util-deprecate@1.0.2 node_modules\util-deprecate
- readable-stream@2.3.3 node_modules\readable-stream
- concat-stream@1.6.0 node_modules\concat-stream
- yauzl@2.4.1 node_modules\yauzl
- del@3.0.0 node_modules\del
- extract-zip@1.6.6 node_modules\extract-zip
- kew@0.7.0 node_modules\kew
- mkdirp@0.5.1 node_modules\mkdirp
- chromedriver@2.33.2 node_modules\chromedriver
npm WARN enoent ENOENT: no such file or directory, open 'C:\WINDOWS\system32\package.json'
npm WARN system32 No description
npm WARN system32 No repository field.
npm WARN system32 No README data
npm WARN system32 No license field.
C:\WINDOWS\system32>npm install chromedriver
> chromedriver@2.33.2 install C:\WINDOWS\system32\node_modules\chromedriver
> node install.js
Downloading https://chromedriver.storage.googleapis.com/2.33/chromedriver_win32.zip
Saving to C:\Users\vadmin\AppData\Local\Temp\chromedriver\chromedriver_win32.zip
Received 781K...
Received 1568K...
Received 2352K...
Received 3136K...
Received 3920K...
Received 4125K total.
Extracting zip contents
Copying to target path C:\WINDOWS\system32\node_modules\chromedriver\lib\chromedriver
Done. ChromeDriver binary available at C:\WINDOWS\system32\node_modules\chromedriver\lib\chromedriver\chromedriver.exe
C:\WINDOWS\system32
`-- chromedriver@2.33.2
+-- del@3.0.0
| +-- globby@6.1.0
| | `-- pify@2.3.0
| +-- p-map@1.2.0
| `-- pify@3.0.0
+-- extract-zip@1.6.6
| +-- concat-stream@1.6.0
| | +-- readable-stream@2.3.3
| | | +-- isarray@1.0.0
| | | +-- process-nextick-args@1.0.7
| | | +-- string_decoder@1.0.3
| | | `-- util-deprecate@1.0.2
| | `-- typedarray@0.0.6
| +-- debug@2.6.9
| | `-- ms@2.0.0
| +-- mkdirp@0.5.0
| `-- yauzl@2.4.1
| `-- fd-slicer@1.0.1
| `-- pend@1.2.0
+-- kew@0.7.0
`-- mkdirp@0.5.1
`-- minimist@0.0.8
npm WARN enoent ENOENT: no such file or directory, open 'C:\WINDOWS\system32\package.json'
npm WARN system32 No description
npm WARN system32 No repository field.
npm WARN system32 No README data
npm WARN system32 No license field.
C:\WINDOWS\system32>npm update chromedriver
C:\WINDOWS\system32>chromedriver -version
ChromeDriver 2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9)
C:\WINDOWS\system32>