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:

UBIK LOAD PACK
  • 33,980
  • 5
  • 71
  • 116
Jyotish
  • 13
  • 4
  • 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 May 05 '18 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. – Jyotish May 06 '18 at 09: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. – Neil Lunn May 06 '18 at 09:04
  • Thanks Neil, Jmeter plugin was downloading older version of Mongodb driver automatically. I excluded the older version using tag. It is working now. Thanks for help. – Jyotish May 07 '18 at 08:34
  • Yes it worked! Thanks @Ubik. I have done it! Thanks a lot! – Jyotish May 09 '18 at 08:27

1 Answers1

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>

UBIK LOAD PACK
  • 33,980
  • 5
  • 71
  • 116
  • I have already kept monog-java-driver 3.6.3 in jmerter lib/ext folder and also added dependency in pom.xml – Jyotish May 06 '18 at 08:58