唠叨一下:
1.将编写好的消费者包打包成jar来测试时,最好把jmeter的/lib/ext文件下其他非Jmeter自带的jar报备份并删掉后,再加入消费者包.jar。然后运行。不然很容易报冲突错误。
2.修改完pom.xml后记得要保存
1、jmeter测试dubbo,将消费者打成jar包放到jmeter的/lib/ext文件夹中后,启动jmeter,进行添加java请求时,报错:
报错信息:(注意下面这几条是或的关系,并不是同时出现的)
1.Configuration error, probably corrupt or missing third party library(jar) ? Could not create class: kg.apc.jmeter.reporters.LoadosophiaUploaderGui. java.lang.NoClassDefFoundError: org/apache/commons/httpclient/methods/multipart/PartSource......Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.methods.multipart.PartSource 或
2.org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 48; schema_reference.4: Failed to read schema document ‘http://code.alibabatech.com/schema/dubbo/dub
bo.xsd‘, because 1) could not find the document; 2) the document could not be re
ad; 3) the root element of the document is not <xsd:schema>.或
3、rg.springframework.beans.factory.parsing.BeanDefinitionParsingException: Config
uration problem: Unable to locate Spring NamespaceHandler for XML schema namespa
ce [http://code.alibabatech.com/schema/dubbo]
Offending resource: class path resource [consumer.xml]
我的解决方法:修改pom.xml。需要进行对依赖进行打包,在<project></project>内加上以下编写:(抄自风落几番的《Jmeter对Dubbo接口进行性能测试》),修改后记得保存pom.xml
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>1.4</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <filters> <filter> <artifact>*:*</artifact> <excludes> <exclude>META-INF/*.SF</exclude> <exclude>META-INF/*.DSA</exclude> <exclude>META-INF/*.RSA</exclude> </excludes> </filter> </filters> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/spring.handlers</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer" > <mainClass>com.fxc.impl.member.MemberProvider</mainClass> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/spring.schemas</resource> </transformer> </transformers> </configuration> </execution> </executions> </plugin> </plugins> </build>
必须吐槽一下:“这一块磨了好久,各种报错。明明看着别人写的和视频是多么容易就添加成功java请求,并运行成功,到我这里就是出不来,最后是看了风落几番的《Jmeter对Dubbo接口进行性能测试》后知道打包原来是需要对依赖进行打包的””
2、jmeter测试dubbo,将消费者打成jar包放到jmeter的/lib/ext文件夹中后,启动jmeter,直接报错,报错信息:
An error occurred: class org.springframework.core.type.classreading.EmptyFieldVi sitor has interface org.springframework.asm.FieldVisitor as super class errorlevel=1
我的解决方法:修改pom.xml在dubbo的依赖上排除spring这个包的依赖如下:(修改后记得保存pom.xml)
<dependency> <groupId>com.alibaba</groupId> <artifactId>dubbo</artifactId> <version>2.5.3</version> <exclusions> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> </exclusion> </exclusions> </dependency>
这个报错应该是不同版本的spring起冲突了,dubbo那自带有个spring,需要把它排除打包,加上<exclusion></exclusion>就能排除掉(不知我理解的对不对)
原文:https://www.cnblogs.com/erliban/p/14402328.html