[英]groovy.lang.MissingMethodException: Error on Jmeter
I'm trying to connect to MongoDB in Jmeter by using JSR223 Sampler.我正在尝试使用 JSR223 采样器连接到 Jmeter 中的 MongoDB。 Here is my code:
这是我的代码:
import com.mongodb.MongoClientURI;
import com.mongodb.MongoClient;
import org.bson.Document;
import com.mongodb.BasicDBObject;
import com.mongodb.ConnectionString;
import com.mongodb.client.FindIterable;
import com.mongodb.client.MongoCursor;
import com.mongodb.client.MongoClients;
import com.mongodb.client.MongoClient;
import com.mongodb.MongoClientSettings;
import com.mongodb.ServerAddress;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import java.util.Arrays;
import com.mongodb.Cursor;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
try {
MongoClientURI connectionString = new MongoClientURI("mymongodb.com:27017");
MongoClient mongoClient = MongoClients.create(connectionString);
MongoDatabase database = mongoClient.getdatabse("mydatbase");
MongoCollection<Document> collection = database.getCollection("employee");
}
catch (Throwable ex) {
log.error("Error in Beanshell", ex);
throw ex;
}
I'm getting error:我收到错误:
ERROR oajpjsJJSR223 Sampler: Error in Beanshell groovy.lang.MissingMethodException: No signature of method: static com.mongodb.client.MongoClients.create() is applicable for argument types: (com.mongodb.MongoClientURI) values: [mymongodb.com:27017] Possible solutions: create(), create(com.mongodb.ConnectionString), create(com.mongodb.MongoClientSettings), create(java.lang.String), create(com.mongodb.ConnectionString, com.mongodb.MongoDriverInformation), create(com.mongodb.MongoClientSettings, com.mongodb.MongoDriverInformation) at groovy.lang.MetaClassImpl.invokeStaticM ERROR oajpjsJJSR223 Sampler: Error in Beanshell groovy.lang.MissingMethodException: No signature of method: static com.mongodb.client.MongoClients.create() is applicable for argument types: (com.mongodb.MongoClientURI) values: [mymongodb.com: 27017] Possible solutions: create(), create(com.mongodb.ConnectionString), create(com.mongodb.MongoClientSettings), create(java.lang.String), create(com.mongodb.ConnectionString, com.mongodb.MongoDriverInformation) , create(com.mongodb.MongoClientSettings, com.mongodb.MongoDriverInformation) at groovy.lang.MetaClassImpl.invokeStaticM issingMethod(MetaClassImpl.java:1518) ~[groovy-all-2.4.16.jar:2.4.16] at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1504) ~[groovy-all-2.4.16.jar:2.4.16] at org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.call(StaticMetaClassSite.java:52) ~[groovy-all-2.4.16.jar:2.4.16] at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) [groovy-all-2.4.16.jar:2.4.16] at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) [groovy-all-2.4.16.jar:2.4.16] at org.codehaus.Z5F202E7AB75F00AF194C61CC0
issingMethod(MetaClassImpl.java:1518) ~[groovy-all-2.4.16.jar:2.4.16] at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1504) ~[groovy-all-2.4.16.jar :2.4.16] at org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.call(StaticMetaClassSite.java:52) ~[groovy-all-2.4.16.jar:2.4.16] at org.codehaus.groovy.runtime .callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) [groovy-all-2.4.16.jar:2.4.16] at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) [ groovy-all-2.4.16.jar:2.4.16] 在 org.codehaus.Z5F202E7AB75F00AF194C61CC0 7AE6B0CZ.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128) [groovy-all-2.4.16.jar:2.4.16] at Script11.run(Script11.groovy:44) [script:?] at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:321) [groovy-all-2.4.16.jar:2.4.16] at org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledScript.java:72) [groovy-all-2.4.16.jar:2.4.16] at javax.script.CompiledScript.eval(CompiledScript.java:89) [java.scripting:?] at org.apache.jmeter.util.JSR223TestElement.processFileOrScript(JSR223TestElement.java:223) [ApacheJMeter_core.jar:
7AE6B0CZ.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128) [groovy-all-2.4.16.jar:2.4.16] at Script11.run(Script11.groovy:44) [script:?] at org. codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:321) [groovy-all-2.4.16.jar:2.4.16] at org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledScript.java:72) [groovy-all-2.4.16.jar:2.4.16] at javax.script.CompiledScript.eval(CompiledScript.java:89) [java.scripting:?] at org.apache.jmeter.util.JSR223TestElement.processFileOrScript( JSR223TestElement.java:223) [ApacheJMeter_core.jar: 5.1.1 r1855137] at org.apache.jmeter.protocol.java.sampler.JSR223Sampler.sample(JSR223Sampler.java:71) [ApacheJMeter_java.jar:5.1.1 r1855137] at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:622) [ApacheJMeter_core.jar:5.1.1 r1855137] at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:546) [ApacheJMeter_core.jar:5.1.1 r1855137] at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486) [ApacheJMeter_core.jar:5.1.1 r1855137] a
5.1.1 r1855137] at org.apache.jmeter.protocol.java.sampler.JSR223Sampler.sample(JSR223Sampler.java:71) [ApacheJMeter_java.jar:5.1.1 r1855137] at org.apache.jmeter.threads.JMeterThread.doSampling (JMeterThread.java:622) [ApacheJMeter_core.jar:5.1.1 r1855137] at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:546) [ApacheJMeter_core.jar:5.1.1 r1855137] at org.apache .jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486) [ApacheJMeter_core.Z68995FCBF432492D15484:351A9D1854Z1]a714A9D18540.1 t org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253) [ApacheJMeter_core.jar:5.1.1 r1855137] at java.lang.Thread.run(Thread.java:834) [?:?]
t org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253) [ApacheJMeter_core.jar:5.1.1 r1855137] at java.lang.Thread.run(Thread.java:834) [?:?]
Anyone has any ideas?有人有什么想法吗? Many Thanks!
非常感谢!
Your code relies on a diamond operator which is not supported in Beanshell.您的代码依赖于 Beanshell 不支持的菱形运算符。
Be aware that starting from JMeter 3.1 you should be using JSR223 Test Elements and Groovy language for scripting so consider choosing groovy
as the scripting language and your code should start working normally请注意, 从 JMeter 3.1 开始,您应该使用 JSR223 测试元素和 Groovy 语言进行脚本编写,因此请考虑选择
groovy
作为正常启动的脚本语言
You might also be interested in MongoDB Performance Testing with JMeter article您可能还对MongoDB 性能测试与 JMeter文章感兴趣
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.