1

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:

5
  • 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. Commented May 5, 2018 at 23:00
  • 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. Commented May 6, 2018 at 9:00
  • 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. Commented May 6, 2018 at 9:04
  • 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. Commented May 7, 2018 at 8:34
  • Yes it worked! Thanks @Ubik. I have done it! Thanks a lot! Commented May 9, 2018 at 8:27

1 Answer 1

2

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>

Sign up to request clarification or add additional context in comments.

1 Comment

I have already kept monog-java-driver 3.6.3 in jmerter lib/ext folder and also added dependency in pom.xml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.