Siva
Siva

Reputation: 123

Problem in JSR223 script, Provider processor

Problem in JSR223 script, Provider processor javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: org.apache.jmeter.threads.JMeterVariables.put() is applicable for argument types: (java.lang.String, java.util.regex.Matcher) values: [callbackUri, java.util.regex.Matcher[pattern=(?<=callbackUri=).*(?=&) region=0,537 lastmatch=]] Possible solutions: put(java.lang.String, java.lang.String), get(java.lang.String), putAt(java.lang.String, java.lang.Object), wait(), dump(), any()

Error in groovy code. The error goes like this "Script144.run(Script144.groovy:2) ~[?:?]"

Trying to fetch a value in from the response of previous GET request.

def redirect = prev.getRedirectLocation()
def redirectQuery = new URI(redirect).query
def callbackUriMatch = (redirectQuery =~ /(?<=callbackUri=).*(? 
=&)/)[0]
vars.put("callbackUri", callbackUriMatch)

The callbackUri is supposed to fetch the value from the previous call. But it is failing to do so.

Upvotes: 0

Views: 953

Answers (1)

Dmitri T
Dmitri T

Reputation: 168157

The main point of this "line" is =~ which is Groovy's match operator, it applies a Regular Expression to the redirect query string in order to get callbackUri parameter from it.

Try amending this line to remove the line break from it:

def callbackUriMatch = (redirectQuery =~ /(?<=callbackUri=).*(?=&)/)[0]

If this doesn't help - try adding some logging by putting log.info() statements to print the variable values to jmeter.log file, like:

def redirect = prev.getRedirectLocation()
log.info('Redirect: ' + redirect)
def redirectQuery = new URI(redirect).query
log.info('Redirect query: ' + redirectQuery)
def callbackUriMatch = (redirectQuery =~ /(?<=callbackUri=).*(?=&)/)[0]
vars.put("callbackUri", callbackUriMatch)

This way you will be able to see some source data for matchers and get some clues regarding how to fix the issue. If you won't be able to do this yourself - update the question with the actual redirect URL so we could come up with the proper regular expression.

Upvotes: 2

Related Questions