Bug 62938 - JSR223 Sampler in jmeter5.0 mongodb3.0 connect questions
Summary: JSR223 Sampler in jmeter5.0 mongodb3.0 connect questions
Status: CLOSED FIXED
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: HTTP (show other bugs)
Version: 5.0
Hardware: PC All
: P2 normal (vote)
Target Milestone: JMETER_5.1
Assignee: JMeter issues mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-22 04:57 UTC by 李伟
Modified: 2018-11-22 06:49 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description 李伟 2018-11-22 04:57:35 UTC
add mongo-java-driver-3.9.0.jar /lib/ext
jsr223 scprits:
import com.mongodb.*
import com.mongodb.MongoCredential
import com.mongodb.BasicDBObject
MongoCredential coreCredential =MongoCredential.createCredential("admin", "admin", "admin".toCharArray());
MongoClient coreMongoClient = new MongoClient(new ServerAddress("${ServerIp}", 27017), Arrays.asList(coreCredential));

error:

javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: static com.mongodb.MongoCredential.createCredential() is applicable for argument types: (java.lang.String, java.lang.String, [C) values: [admin, admin, admin]
	at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:320) ~[groovy-all-2.4.10.jar:2.4.10]
	at org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledScript.java:72) ~[groovy-all-2.4.10.jar:2.4.10]
	at javax.script.CompiledScript.eval(Unknown Source) ~[?:1.8.0_131]
	at org.apache.jmeter.util.JSR223TestElement.processFileOrScript(JSR223TestElement.java:221) ~[ApacheJMeter_core.jar:5.0 r1840935]
	at org.apache.jmeter.protocol.java.sampler.JSR223Sampler.sample(JSR223Sampler.java:71) [ApacheJMeter_java.jar:5.0 r1840935]
	at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:622) [ApacheJMeter_core.jar:5.0 r1840935]
	at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:546) [ApacheJMeter_core.jar:5.0 r1840935]
	at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486) [ApacheJMeter_core.jar:5.0 r1840935]
	at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253) [ApacheJMeter_core.jar:5.0 r1840935]
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_131]
Caused by: groovy.lang.MissingMethodException: No signature of method: static com.mongodb.MongoCredential.createCredential() is applicable for argument types: (java.lang.String, java.lang.String, [C) values: [admin, admin, admin]
	at groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1506) ~[groovy-all-2.4.10.jar:2.4.10]
	at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1492) ~[groovy-all-2.4.10.jar:2.4.10]
	at org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.call(StaticMetaClassSite.java:53) ~[groovy-all-2.4.10.jar:2.4.10]
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) ~[groovy-all-2.4.10.jar:2.4.10]
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) ~[groovy-all-2.4.10.jar:2.4.10]
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:141) ~[groovy-all-2.4.10.jar:2.4.10]
	at Script22.run(Script22.groovy:4) ~[?:?]
	at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:317) ~[groovy-all-2.4.10.jar:2.4.10]
	... 9 more


but, in jmeter3.2 that's ok
Comment 1 Felix Schumacher 2018-11-22 06:11:07 UTC
JMeter comes with a very old copy of MongoDB client library. You will have to remove those from the JMeter class path before you can add a newer version.

This report can basically be split in two things:

 - an enhancement request to update the MongoDB client library.
 - a question on how to add jars to JMeter without shooting oneself into ones own foot.

The first one is difficult and has been discussed before on the mailing list. The second would be a good candidate to be asked on the mailing list.

I am therefore closing this report as invalid. Feel free to ask on the mailing list for more help if needed.
Comment 2 李伟 2018-11-22 06:49:55 UTC
yes, I put in the wrong directory, that's  "lib/mongo-java-driver-3.9.0.jar"
Comment 3 The ASF infrastructure team 2022-09-24 20:38:15 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/4928