0

I'm kind of new to Groovy and now rework JS script to Groovy in JMeter. I've got persistent error No signature of method: static java.lang.String.ValueOf() is applicable for argument types: (java.lang.String) values: [1572245927833] when run in code below in JSR223 Groovy in JMeter, the error for line number with return statement:

def clientTransactionIdGen() {
    String timestamp = new Date().getTime().toString();
    def rand = get_random(1000000, 9999999);
    def user_id = vars.get("user_id");
    return timestamp + String.valueOf(rand) + '^' + user_id;
}

1572245927833 is time in seconds (so timestamp variable) and there is no ValueOf() conversion in line with return statement. I even changed timestamp type from def to String, still error points to line with return statement. Why such error in such place? As I understand there is a try to convert already string object to String. Why? The same error actually is when I have timestamp as long and convert in return line, also a puzzle to me:

def clientTransactionIdGen() {
    def timestamp = new Date().getTime();
    def rand = get_random(1000000, 9999999);
    def user_id = vars.get("user_id");
    return String.valueOf(timestamp) + String.valueOf(rand) + '^' + user_id;
}

ADDED: per good remarks changed all ValueOf to valueOf in all script, still the error as above stays and says: No signature of method: static java.lang.String.ValueOf()

ADDED: solved after reload of JMeter, apparently something remained cached and did not allow for proper debugging.

7
  • It says you are trying to parse a String to a String, which is pointless. Change String.ValueOf(rand) into simply rand Commented Oct 28, 2019 at 7:19
  • @michalk if that was the problem, he would already get errors on the timestamp parsing. Commented Oct 28, 2019 at 7:19
  • String.ValueOf() -> String.valueOf(): it's case-sensitive Commented Oct 28, 2019 at 7:20
  • @ernest_k, I've changed ValueOf to valueOf in the function - still same error Commented Oct 28, 2019 at 7:23
  • 1
    @ernest_k, after app (JMeter) reload error is no longer there, thank you! Commented Oct 28, 2019 at 7:38

1 Answer 1

2

Java methods start with lower case valueOf:

return timestamp + String.valueOf(rand) + '^' + user_id;
Sign up to request clarification or add additional context in comments.

2 Comments

@AlexeiMartianov error can't remain ValueOf, maybe you have more code using ValueOf instead of valueOf
thank you, following @ernest_k remark of cached, I restarted and error went away.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.