4
votes

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";
1
what is the JMeter version? where did you keep the couchbase-client-java jars? in /lib folder? what all libraries required?Naveen Kumar R B
I am using 2.11 ,yes. I have kept them in lib folderkmn
please let me know what all libraries required and the links to download themNaveen Kumar R B
You need the two couchbase jars and the rxjava onekmn

1 Answers

1
votes

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:

  1. http://docs.couchbase.com/sdk-api/couchbase-java-client-2.0.0/index.html?com/couchbase/client/java/CouchbaseCluster.html

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:

  1. https://www.blazemeter.com/blog/beanshell-vs-jsr223-vs-java-jmeter-scripting-its-performance