Mongo-java-driver: fail to execute aggregate($sampler) in Groovy

Hi Team,

I’m developing performance tests scenarios with Jmeter, using java-driver in groovy [3.12.8].

MongoClientURI uri = new MongoClientURI("...");
 	MongoClient client = new MongoClient(uri);
 	DB db = client.getDB("...");
 	DBCollection collection = db.getCollection("cartoes");
	**DBCursor cursor = collection.aggregate([{$sampler:{size:6000}}]);**

When I trie to execute that, I’ve that error:

Response message:javax.script.ScriptException: javax.script.ScriptException: java.lang.ClassCastException: class Script1$_run_closure1 cannot be cast to class com.mongodb.DBObject (Script1$_run_closure1 is in unnamed module of loader groovy.lang.GroovyClassLoader$InnerLoader @56bd9b46; com.mongodb.DBObject is in unnamed module of loader org.apache.jmeter.DynamicClassLoader @a09ee92)

If I use an simple find() instead of aggregate, it’s run.
If I run the same aggregate in robot3T GUI, it’s run too.

Any ideas? It’s possible do it?

Thanks !!