Reputation: 41
I am getting error message
Error invoking bsh method: eval Sourced file: inline evaluation of: ``import java.util.Arrays; import java.util.List; import java.util.concurrent.Time . . . '' : Typed variable declaration : Error in method invocation: Static method create( java.lang.String ) not found in class'com.couchbase.client.java.CouchbaseCluster'
when I execute jmeter script with Beanshell Post Processor. Any thoughts on why I am seeing this error?
Here is the sample code: import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
import com.couchbase.client.java.Bucket;
import com.couchbase.client.java.Cluster;
import com.couchbase.client.java.CouchbaseCluster;
import com.couchbase.client.java.document.Document;
import com.couchbase.client.java.document.JsonDocument;
import com.couchbase.client.java.document.json.JsonObject;
Cluster cluster = CouchbaseCluster.create("dev-int-couchbase1.aeg.cloud");
Bucket bucket = cluster.openBucket("source-image ",100, TimeUnit.MINUTES);
Document<JsonObject> loadedFromDoc = bucket.get("0292ofcfh4516");
if(loadedFromDoc == null)
return "Document Not found";
bucket.remove(“0292ofcfh4516");
log.info("In bean shell processor");
System.out.println("In bean shell processor");
cluster.disconnect();
return "Document Removed";
Upvotes: 4
Views: 2964
Reputation: 6398
Instead of using create(String... varargs)
method, suggest using create(List<String> nodes)
method.
replace the following code
Cluster cluster = CouchbaseCluster.create("dev-int-couchbase1.aeg.cloud");
With:
nodes = new ArrayList();
nodes.add("dev-int-couchbase1.aeg.cloud");
Cluster cluster = CouchbaseCluster.create(nodes);
Note: I am not sure how to fix the issue related to varargs
, so suggesting another one. I tried suggested method here, but did not work for varargs
.
Reference:
I suggest use JSR223 Post Processor instead of BeanShell postprocessor
. Just copy paste the code from BeanShell
to JSR223
and select the language as Java
under script language
drop-down available in the JSR223 post processor
.
This gives more flexibility in debugging (prints complete stack trace of the error/exception in the logs).
Coming to the error, it says that Static method create( java.lang.String ) not found in class'com.couchbase.client.java.CouchbaseCluster
. I checked in the official docs here, which says there is a create
method which takes String Varargs
. I ma not sure whether that is causing the issue. so, try it out in JSR223 PostProcessor and debug the issue.
References:
Upvotes: 1