apache / apache/jmeter

Need to update Mongo related jars to latest version

Open
#6,052 2 comments 1 reaction 0 assignees View on GitHub
defect to-triage
Dominant language
Java
Stars
9.5k
Forks
2.3k
Avg merge
1d 22h
Merged PRs (30d)
5

Description

### Expected behavior

Current version of Jmeter is having " ApacheJMeter_mongodb.jar " & "mongo-java-driver-2.11.3.jar" in lib folder of Jmeter .
With these given version of these jar we canot connect to mongo atlas using connection string with groovy .

Expected behaviour is the given jar should allow us to connect with mongo but its not working as expected.

### Actual behavior

Here is the sample of groovy code which is required to connect with mongo -

import com.mongodb.MongoClient;
import com.mongodb.MongoClientURI;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.MongoCollection;
import org.bson.Document;
import static com.mongodb.client.model.Filters.eq
import com.mongodb.client.MongoClients;
import com.mongodb.MongoClientSettings;

String connectionString = "";
MongoClientURI uri = new MongoClientURI(connectionString);
MongoClient mongoClient = new MongoClient(uri);
MongoDatabase database = mongoClient.getDatabase("");
MongoCollection collection = database.getCollection("");

Currently if we run the above code after passing the right details of connection name , DB name and collection name there will be compilation issues like :-

Response message:javax.script.ScriptException: javax.script.ScriptException: org.bson.json.JsonParseException: JSON reader was expecting a value but found '$'.

Response message:javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.$() is applicable for argument types: (Script12$_run_closure1) values: [Script12$_run_closure1@995f58e]
Possible solutions: is(java.lang.Object), any(), get(java.lang.String), use([Ljava.lang.Object;), any(groovy.lang.Closure), tap(groovy.lang.Closure)

To reslove all these issues and to connect with Mongo atlas using connection string in groovy code :-

1) we need to replace "ApacheJMeter_mongodb.jar" with "ApacheJMeter_mongodb-5.6.jar in lib folder of JMeter . this jar can be downloaded from https://mvnrepository.com/artifact/org.apache.jmeter/ApacheJMeter_mongodb/5.6
2) we need to replace "mongo-java-driver-2.11.3.jar" with "mongo-java-driver-3.12.13.jar " in lib folder of JMeter.this jar can be downloaded from https://mvnrepository.com/artifact/org.mongodb/mongo-java-driver/3.12.13
3) Add "bson-4.9.1.jar " to lib folder of Jmeter . download link https://mvnrepository.com/artifact/org.mongodb/bson/4.9.1

4) Copy the ApacheJMeter_mongodb-5.6.jar , mongo-java-driver-3.12.13.jar and bson-4.9.1.jar to ext folder as well in lib of JMeter

### Steps to reproduce the problem

Install the JMeter 5.6 ,using groovy code in JSR223 sampler try to connect with mongo atlas using the connection string rather than host and port .

you will run into mullipr issues as mention above .

After adding /replacing the files as mentioned above will resolve all these issues and a successful connection can be set up .

### JMeter Version

5.6

### Java Version

openjdk 17

### OS Version

macOS - Ventura 13.4.1

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.