Service Virtualization

 View Only
  • 1.  Getting error in Execute Script

    Posted Jan 22, 2022 08:50 AM
    Hai Guys,

    can anyone pls help me how to resolve it. getting error like this



    ============================================================================
    | Error in Script
    ============================================================================
    | Step: Execute script (JSR-223)
    ----------------------------------------------------------------------------
    | Message: bsh.TargetError: Sourced file: inline evaluation of: ``import java.util.regex.*; String accountNumber = testExec.getStateValue(" . . . '' : Typed variable declaration : at Line: 5 : in file: inline evaluation of: ``import java.util.regex.*; String accountNumber = testExec.getStateValue(" . . . '' : .toString ( )

    Target exception: java.lang.NullPointerException: Attempt to invoke method toString on null value

    Target exception: java.lang.NullPointerException: Attempt to invoke method toString on null value
    in inline evaluation of: ``import java.util.regex.*; String accountNumber = testExec.getStateValue(" . . . '' at line number 5
    ----------------------------------------------------------------------------
    | Trapped Exception: bsh.TargetError: Sourced file: inline evaluation of: ``import java.util.regex.*; String accountNumber = testExec.getStateValue(" . . . '' : Typed variable declaration : at Line: 5 : in file: inline evaluation of: ``import java.util.regex.*; String accountNumber = testExec.getStateValue(" . . . '' : .toString ( )

    Target exception: java.lang.NullPointerException: Attempt to invoke method toString on null value

    Target exception: java.lang.NullPointerException: Attempt to invoke method toString on null value
    in inline evaluation of: ``import java.util.regex.*; String accountNumber = testExec.getStateValue(" . . . '' at line number 5
    | Trapped Message: javax.script.ScriptException: bsh.TargetError: Sourced file: inline evaluation of: ``import java.util.regex.*; String accountNumber = testExec.getStateValue(" . . . '' : Typed variable declaration : at Line: 5 : in file: inline evaluation of: ``import java.util.regex.*; String accountNumber = testExec.getStateValue(" . . . '' : .toString ( )

    Target exception: java.lang.NullPointerException: Attempt to invoke method toString on null value

    Target exception: java.lang.NullPointerException: Attempt to invoke method toString on null value
    in inline evaluation of: ``import java.util.regex.*; String accountNumber = testExec.getStateValue(" . . . '' at line number 5
    ----------------------------------------------------------------------------
    STACK TRACE
    javax.script.ScriptException: bsh.TargetError: Sourced file: inline evaluation of: ``import java.util.regex.*; String accountNumber = testExec.getStateValue(" . . . '' : Typed variable declaration : at Line: 5 : in file: inline evaluation of: ``import java.util.regex.*; String accountNumber = testExec.getStateValue(" . . . '' : .toString ( )

    Target exception: java.lang.NullPointerException: Attempt to invoke method toString on null value

    Target exception: java.lang.NullPointerException: Attempt to invoke method toString on null value
    in inline evaluation of: ``import java.util.regex.*; String accountNumber = testExec.getStateValue(" . . . '' at line number 5
    at bsh.BshScriptEngine.evalSource(BshScriptEngine.java:97)
    at bsh.BshScriptEngine.eval(BshScriptEngine.java:61)
    at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
    at com.itko.lisa.test.ScriptExecHandler.executeScript(ScriptExecHandler.java:673)
    at com.itko.lisa.test.ScriptExecHandler.executeScript(ScriptExecHandler.java:426)
    at com.itko.lisa.test.UserScriptNode._execute(UserScriptNode.java:200)
    at com.itko.lisa.test.UserScriptNode.execute(UserScriptNode.java:170)
    at com.itko.lisa.test.TestNode.executeNode(TestNode.java:995)
    at com.itko.lisa.test.TestCase.execute(TestCase.java:1297)
    at com.itko.lisa.test.TestCase.execute(TestCase.java:1198)
    at com.itko.lisa.test.TestCase.executeNextNode(TestCase.java:1183)
    at com.itko.lisa.editor.WalkThruPanel.prepAndExecNode(WalkThruPanel.java:1123)
    at com.itko.lisa.editor.WalkThruPanel.access$900(WalkThruPanel.java:73)
    at com.itko.lisa.editor.WalkThruPanel$10.doCallback(WalkThruPanel.java:1022)
    at com.itko.util.swing.panels.ProcessingDialog$2.run(ProcessingDialog.java:195)
    at java.lang.Thread.run(Thread.java:748)
    Caused by: java.lang.NullPointerException: Attempt to invoke method toString on null value
    at bsh.Reflect.resolveExpectedJavaMethod(Reflect.java:382)
    at bsh.Reflect.invokeObjectMethod(Reflect.java:91)
    at bsh.BSHPrimarySuffix.doName(BSHPrimarySuffix.java:168)
    at bsh.BSHPrimarySuffix.doSuffix(BSHPrimarySuffix.java:112)
    at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:72)
    at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:39)
    at bsh.BSHVariableDeclarator.eval(BSHVariableDeclarator.java:78)
    at bsh.BSHTypedVariableDeclaration.eval(BSHTypedVariableDeclaration.java:76)
    at bsh.Interpreter.eval(Interpreter.java:673)
    at bsh.Interpreter.eval(Interpreter.java:764)
    at bsh.Interpreter.eval(Interpreter.java:753)
    at bsh.BshScriptEngine.evalSource(BshScriptEngine.java:89)
    ... 15 more
    ============================================================================


  • 2.  RE: Getting error in Execute Script

    Broadcom Employee
    Posted Jan 22, 2022 02:26 PM
    Hi Bhaskara,

    Could you post the first 5 lines of your script so we can understand where the error occurs. The error is on line 5. There should be a toString() method call on that line.

    Cheers,

    Danny Saro

    Client Services Consultant

    Broadcom Software


    -------------------------------------------------


    This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it.





  • 3.  RE: Getting error in Execute Script

    Posted Jan 23, 2022 12:33 AM
    Hai danny,

    i copied the first 5 lines from the script and pasted it here. can you check it once.


    import java.util.regex.*;



    String accountNumber = testExec.getStateValue("accountNumber").toString();


  • 4.  RE: Getting error in Execute Script

    Broadcom Employee
    Posted Jan 23, 2022 05:37 AM
    Hi Bhaskara,

    The error in the script indicates that within the flow at the moment the script executes the property with the name "accountNumber" does not exist.

    testExec.getStateValue("accountNumber") retrieves a null value - what happens when it does not exist - and then executing the method .toString() on a null value gives the error: java.lang.NullPointerException: Attempt to invoke method toString on null value

    You will have to check for misspelling of the name "accountNumber" in this script, or at the step in the flow where the property is created. Be aware property names are case sensitive.

    Or maybe there are paths through the flow that skip the step where the property gets created?

    Cheers,

    Danny Saro

    Client Services Consultant

    Broadcom Software


    -------------------------------------------------


    This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it.





  • 5.  RE: Getting error in Execute Script

    Posted Jan 23, 2022 08:18 AM
    Hai Danny,

    yeah now it's working but after executing script step it directly ending the test. it is not going to other steps and in the response i am getting page isn't responding. (in the execute script JSR-223 step i add some assertions like postiveScenerio and NegativeScenario. so when i run it locally it only going to listener and execute script JSR-223 steps only and after that it directly ending the test.)


  • 6.  RE: Getting error in Execute Script

    Broadcom Employee
    Posted Jan 23, 2022 08:43 AM
    Hi Bhaskara,

    You will need to give some more context and info about what you're trying to do.

    I assume this is a Virtual Service - so a VSM model - that you are testing locally - so you're running it in the ITR - , if not then please correct.

    You need to look for a reason why it is ending the test (you mention "test" but I am still assuming that it is a VSM so a virtual service and not a testcase), it could be that you're assertions are not correctly configured eg. you switched the  "if true" or "if false". Also, in a VSM any assertions that deal with functional logic should never "end" the test, the "next" of an assertion in this case should always be some other step. A virtual service model should be a never-ending loop.

    If it is not your assertions then something else is wrong in the step, have a look in the "System Messages" (ie. the log) of your workstation to see if there are any java exceptions when your failing step is executing. 
     
    Cheers,

    Danny Saro

    Client Services Consultant

    Broadcom Software


    -------------------------------------------------


    This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it.





  • 7.  RE: Getting error in Execute Script

    Posted Jan 24, 2022 09:23 AM
    Hai Danny,

    All my issues were resolved by one SubjectMatterExpert. Thank you for your support and response and sorry for the delay.

    Cheers : )