Service Virtualization

Expand all | Collapse all

Getting "java.lang.SecurityException: Scripts cannot call Runtime.exec()" error

  • 1.  Getting "java.lang.SecurityException: Scripts cannot call Runtime.exec()" error

    Posted Jul 17, 2018 10:27 AM

    Hi All,

     

    I have created a custom jar and i am trying to call one of its method in my test script. However, i am getting the below error.

     

    ============================================================================

    | Error in Script

    ============================================================================

    | Step:        Execute script (JSR-223)

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

    | Message:     bsh.TargetError: Sourced file: inline evaluation of: ``import com.org.swagger.code.Checkout;  import java.lang.Runtime.*;     Checkout  . . . '' : Method Invocation co.cloneRepository : at Line: 8 : in file: inline evaluation of: ``import com.org.swagger.code.Checkout;  import java.lang.Runtime.*;     Checkout  . . . '' : co .cloneRepository ( "https://myhost:myport/bitbucket/scm/nagr/repo.git" , "C:\Users\username\LocalRepo")

     

    Target exception: java.lang.SecurityException: Scripts cannot call Runtime.exec()

    in inline evaluation of: ``import com.org.swagger.code.Checkout;  import java.lang.Runtime.*;     Checkout  . . . '' at line number 8.

     

    Please suggest.



  • 2.  Re: Getting "java.lang.SecurityException: Scripts cannot call Runtime.exec()" error
    Best Answer

    Broadcom Employee
    Posted Jul 17, 2018 01:01 PM

    Hi,

     

    The security sandbox of the script interpreter disallows certain operations like Runtime.exec() and System.exit().

     

    I suggest refactoring your test case to use the "Execute External Command" step.

     

    --Mike