1
votes

I am trying to connect to mongodb using JSR 223 sampler with groovy. THe signature looks completely fine and The script works fine in JMETER. But it throws error while executing it through maven. Below is the code:

==================

MongoCredential mongoCredential = MongoCredential.createScramSha1Credential("PIDPCR","adm",'pRU6Ref'.toCharArray()); coreMongoClient = new MongoClient(new ServerAddress("${addr}", 27017),Arrays.asList(mongoCredential));

=================

Below is the error thrown:

javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: static com.mongodb.MongoCredential.createScramSha1Credential() is applicable for argument types: (java.lang.String, java.lang.String, [C) values:

1
Sounds like you have not installed a jar correctly. Clean everything out, check you pom.xml for "official" and relevant sources and fetch all the dependencies again. And actually use maven for that, just in case you previously thought copying a downloaded file was okay before. - Neil Lunn
I already have added dependencies and i have another mongodb server which do not requires authentication and i do not have to use mongoCredential, it works fine in that case. - Jyotish
The reason we mention this to you ( twice ) is because this is typically the cause of the error when there is a mismatch between the compiled code and library installed in the jar from what it originally referred to. So you're definitely breaking something there. The provided answer is the most likely cause of this. Check ALL your class path values and make sure that only the expected jar is actually there. - Neil Lunn
Thanks Neil, Jmeter plugin was downloading older version of Mongodb driver automatically. I excluded the older version using <excludedArtifacts> tag. It is working now. Thanks for help. - Jyotish
Yes it worked! Thanks @Ubik. I have done it! Thanks a lot! - Jyotish

1 Answers

1
votes

JMeter embeds an old version of mongo-java-driver-2.11.3.jar.

So ensure you remove it and add the version that works for your code.

To exclude you can use this tag as per this documentation:

<excludedArtifacts>