Renu-Lamba opened a new issue, #6052:
URL: https://github.com/apache/jmeter/issues/6052

   ### 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 = "<your connection string details>";
   MongoClientURI uri = new MongoClientURI(connectionString);
   MongoClient mongoClient = new MongoClient(uri);
   MongoDatabase database = mongoClient.getDatabase("<your database name>");
   MongoCollection<Document> collection = database.getCollection("<your 
collection name >");
   
   
   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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@jmeter.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to