简体   繁体   English

groovy.lang.MissingMethodException:Jmeter 上的错误

[英]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.

相关问题 如何处理 groovy.lang.MissingMethodException - How to deal with groovy.lang.MissingMethodException 如何修复groovy.lang.MissingMethodException:没有方法的签名 - how to fix groovy.lang.MissingMethodException: No signature of method 运行代码为 a.jar 时出现 groovy.lang.missingMethodException - groovy.lang.missingMethodException when running code as a .jar groovy.lang.MissingMethodException:方法的无签名:java.util.ArrayList - groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList eachParallel() 在使用 GPars 时抛出 groovy.lang.MissingMethodException - eachParallel() throwing groovy.lang.MissingMethodException when using GPars Android Studio 错误 - groovy.lang.MissingMethodException:没有方法签名:build_8sqj**q9.android() 适用于参数类型:*** - Android Studio error - groovy.lang.MissingMethodException: No signature of method: build_8sqj**q9.android() is applicable for argument types: *** groovy.lang.MissingMethodException:无方法签名:java.lang.String.name() 适用于参数类型:() 值:[] - groovy.lang.MissingMethodException: No signature of method: java.lang.String.name() is applicable for argument types: () values: [] 通过集成测试用例发送到服务的参数有问题:groovy.lang.MissingMethodException - Params sent through integration test case to the service having an issue:groovy.lang.MissingMethodException groovy.lang.MissingMethodException:方法的无签名:java.io.FileWriter.append() - groovy.lang.MissingMethodException: No signature of method: java.io.FileWriter.append() 无法在jsonarray上使用isEmpty方法,它给出了异常groovy.lang.MissingMethodException:没有方法的签名 - Cannot use isEmpty method on a jsonarray, it gives exception groovy.lang.MissingMethodException: No signature of method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM