0

I have already tried with this below code but it is showing Caused by:

javax.script.ScriptException: java.lang.NullPointerException: Cannot invoke method getValue() on null object
    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:324) ~[groovy-all-2.4.16.jar:2.4.16]
    at org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledScript.java:72) ~[groovy-all-2.4.16.jar:2.4.16]
    at javax.script.CompiledScript.eval(Unknown Source) ~[?:1.8.0_202]
    at org.apache.jmeter.util.JSR223TestElement.processFileOrScript(JSR223TestElement.java:223) ~[ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.extractor.JSR223PostProcessor.process(JSR223PostProcessor.java:44) [ApacheJMeter_components.jar:5.1.1 r1855137]
    at org.apache.jmeter.threads.JMeterThread.runPostProcessors(JMeterThread.java:925) [ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:564) [ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486) [ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253) [ApacheJMeter_core.jar:5.1.1 r1855137]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_202]
Caused by: java.lang.NullPointerException: Cannot invoke method setValue() on null object
    at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:91) ~[groovy-all-2.4.16.jar:2.4.16]
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:47) ~[groovy-all-2.4.16.jar:2.4.16]
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) ~[groovy-all-2.4.16.jar:2.4.16]
    at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:34) ~[groovy-all-2.4.16.jar:2.4.16]
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) ~[groovy-all-2.4.16.jar:2.4.16]
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) ~[groovy-all-2.4.16.jar:2.4.16]
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128) ~[groovy-all-2.4.16.jar:2.4.16]
    at org.purestudy.encryption.Script77.run(Script77.groovy:32) ~[?:?]
    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:321) ~[groovy-all-2.4.16.jar:2.4.16]
java.lang.NullPointerException: Cannot invoke method setValue() on null object

This is the code i have implemented but it is only accepting for the arguments passed and encrypted with jsr223 preproccessor in bodydata but not working for which wecan't apply preproccessor & this is written jsr223 post proccessor

 **String encryptedText= "${ENCRYPTEDResponseofprevREQ}";
   log.info(encryptedText);

   String decryptedText = new OpenSSLEncryptDecrypt().decrypt(encryptedText);
   log.info(decryptedText);

   ctx.getCurrentSampler().getArguments().getArgument(0).getValue(decryptedText);

   vars.put("variable",decryptedText);
   def my_var1 = vars.get("variable");
  
   log.info(my_var1);
   ctx.getCurrentSampler().getArguments().getArgument(0).setValue(my_var1);**

2 Answers2

0

This line:

ctx.getCurrentSampler().getArguments().getArgument(0).getValue(decryptedText);

causes the error because ctx.getCurrentSampler().getArguments().getArgument(0) returns null and you're trying to invoke getValue() function on a null object.

Demo:

enter image description here

It's hard to say how to fix the issue without knowing what you're trying to achieve, but 2 things are obvious:

  1. Your HTTP Request sampler doesn't have arguments - that's why you're getting this error
  2. There is no such a function getValue(String), the function getValue() takes no parameters

See Apache Groovy - Why and How You Should Use It article for more information on Groovy scripting in JMeter

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
0

Yes in http request there are no arguments I need the code to extract the value from that sampler which is encrypted to store in the next sampler Dmitri T