I never got to the bottom of the above issue but found another solution which is probably a better one. In JMeter, I added a BSF PostProcessor instead of a Bean shell script. I chose javascript (the lowercase version) as my language and wrote a short script to perform what I needed to do.
Getting typed variable declaration error in a JMeter bean shell script
Question
I have this short script in a Bean Shell Post Processor. It uses the GSON library to parse JSON into a Bean. I'm now trying to convert back to JSON using the toJson method but receive this error:
Typed variable declaration : Method Invocation gson.toJson
Code:
import com.google.gson.Gson;
public class SavedSearch {
public String id;
}
Gson gson = new Gson();
SavedSearch savedSearch = new SavedSearch();
String newJsonFile = gson.toJson(savedSearch);
vars.put("jobSavedResponse", newJson);
Any suggestions on how to fix this?
Solution
OTHER TIPS
If there's an exception thrown, then you'll get this error. Maybe 'savedSearch' had a marshalling error? Did you try running a unit test with this code?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow