Service Virtualization

Expand all | Collapse all

Error in Execute script(JSR-223)

Suresh1992

Suresh1992Jan 05, 2018 03:32 AM

  • 1.  Error in Execute script(JSR-223)

    Posted Jan 02, 2018 02:09 AM

    Hi All,

     

    I am getting following error in execute script(JSR -223) step.

    Could not find the runtime language engine for 'javascript', please ensure the provider jar is in the classpath.

    Also find the same error screen shot below.

     

    When i tried to write some code in the step its thowring an error which is syntax error. Even for simple code return true; its giving an error. And defalult script is Beanshell, So that i opened the local.properties file where as i could not find  lisa.scripting.default.language=beanshell line. So that added the same line manaully in local.propties file and ran the workstation. But still its showing beanshell is the default language and throwing above highlited error.

     

    Can anyone please help me to over come this error and use JSR step?

     

     

    Thanks,

    Suresh N



  • 2.  Re: Error in Execute script(JSR-223)

    Posted Jan 02, 2018 05:15 AM

    Hello Suresh,

     

    Assuming that you are running DevTest 10.1 or 10.2. It appears that the scripting engine for javascript is not found/loaded. The following test checks whether all the OOTB supported scripting engines are available to DevTest. Please note that the javascript engine is loaded from JRE subsystem that comes with DevTest. 

     

    1. Open the 'examples' project in <installdir>\examples. It comes with the product installation.
    2. Run test case 'scripting.tst' in ITR. It validates pre-installed scriping languages JavaScript, Beanshell and Groovy. The test case should complete successfully.
    3. Once the test case is run, verify that in workstation.log you find following log entries close to the end of the log file:

    INFO com.itko.lisa.test.UserScriptNode - JSR223 language engine velocity 1.5 for language velocity 1.5 (Velocity velocity ) from file:<installdir>/lib/shared/itko-velocity-engine-1.7.jar
    INFO com.itko.lisa.test.UserScriptNode - JSR223 language engine BeanShell Engine 2.1.8 for language BeanShell 2.1.8 (beanshell bsh ) from file:<installdir>/lib/shared/bsh-2.1.8.jar
    INFO com.itko.lisa.test.UserScriptNode - JSR223 language engine Groovy Scripting Engine 2.0 for language Groovy 2.4.7 (groovy Groovy ) from file:<installdir>/lib/shared/groovy-all-2.4.7.jar
    INFO com.itko.lisa.test.UserScriptNode - JSR223 language engine Oracle Nashorn 1.8.0_102 for language ECMAScript ECMA - 262 Edition 5.1 (nashorn Nashorn js JS JavaScript javascript ECMAScript ecmascript ) from file:<installdir>/jre/lib/ext/nashorn.jar

     

    Regards,

     

    Ulrich



  • 3.  Re: Error in Execute script(JSR-223)

    Posted Jan 02, 2018 06:00 AM

    Hi Ulrich,

    I did run the example scripting.tst on ITR. All steps got successed. StillI am getting error in JSR223 step.

     

    Do i need to add any third party jar file? or anything need to be added in local.propeties file?

     

    Thanks,

    Suresh N



  • 4.  Re: Error in Execute script(JSR-223)

    Posted Jan 02, 2018 06:12 AM

    Did you check workstation.log for the log entries I mentioned? Can you please confirm the DevTest version you are running? There is no need to change local.properties if you want to use one of the scripting engines that are supported OOTB. All the required jar files for the scripting engines are part of the installation. Have you configured DevTest to use a different JRE than the default one in <DevTest installdir>\jre?



  • 5.  Re: Error in Execute script(JSR-223)

    Posted Jan 02, 2018 06:18 AM

    Hi Ulrich,

     

    Did you check workstation.log for the log entries I mentioned?

    I could not find workstation.log file in <lisatmp_10.1.0> folder.

    Can you please confirm the DevTest version you are running?

    10.1 version

    Have you configured DevTest to use a different JRE than the default one in <DevTest installdir>\jre?

    No. Not added any external jre.

     

    Thanks,

    Suresh N



  • 6.  Re: Error in Execute script(JSR-223)

    Posted Jan 02, 2018 06:43 AM

    Assuming you are running DevTest on Windows, you will find workstation.log in %USERPROFILES%\lisatmp_10.1.0. 



  • 7.  Re: Error in Execute script(JSR-223)

    Posted Jan 02, 2018 06:58 AM

    Hi Ulrich,

     

    Yes. i could see below logs in workstation.log file.

     

    INFO  com.itko.lisa.test.UserScriptNode - JSR223 language engine velocity 1.5 for language velocity 1.5 (Velocity velocity ) from file:/C:/Program%20Files/CA/DevTest/lib/shared/itko-velocity-engine-1.7.jar
    2018-01-02 11:51:42,213Z (20:51) [ProcDlgThreadCallbk@1a60a885] INFO  com.itko.lisa.test.UserScriptNode - JSR223 language engine Groovy Scripting Engine 2.0 for language Groovy 2.4.7 (groovy Groovy ) from file:/C:/Program%20Files/CA/DevTest/lib/shared/groovy-all-2.4.7.jar
    2018-01-02 11:51:42,214Z (20:51) [ProcDlgThreadCallbk@1a60a885] INFO  com.itko.lisa.test.UserScriptNode - JSR223 language engine Oracle Nashorn 1.8.0_102 for language ECMAScript ECMA - 262 Edition 5.1 (nashorn Nashorn js JS JavaScript javascript ECMAScript ecmascript ) from file:/C:/Program%20Files/CA/DevTest/jre/lib/ext/nashorn.jar
    2018-01-02 11:51:42,214Z (20:51) [ProcDlgThreadCallbk@1a60a885] INFO  com.itko.lisa.test.UserScriptNode - JSR223 language engine BeanShell Engine 2.1.8 for language BeanShell 2.1.8 (beanshell bsh ) from file:/C:/Program%20Files/CA/DevTest/lib/shared/bsh-2.1.8.jar

     

    After this, Do i need to set environment variable path?

     

    Thanks,

    Suresh N



  • 8.  Re: Error in Execute script(JSR-223)

    Posted Jan 02, 2018 02:48 PM

    No, you do not have to set any configuration parameter or environment variable to use the OOTB scripting engines in DevTest. If you execute the script again triggering the error and then share the workstation.log file we might get additional information about the root cause. 



  • 9.  Re: Error in Execute script(JSR-223)

    Broadcom Employee
    Posted Jan 02, 2018 04:49 PM

    Suresh,

     

    Ulrich is right, test DevTest OOTB you should not have to set anything.

     

    Please try this, bring up a command prompt.

     

    cd to DEVTEST_HOME/lib/shared.

     

    execute this command: dir > shared_output.txt

     

    attach the file shared_output.txt to this post.



  • 10.  Re: Error in Execute script(JSR-223)

    Posted Jan 03, 2018 03:16 AM
      |   view attached

    Hi Marcy,

     

    PFA shared_output.txt .

     

    Thanks,

    Suresh

    Attachment(s)

    zip
    shared_output.txt.zip   5 KB 1 version


  • 11.  Re: Error in Execute script(JSR-223)

    Posted Jan 03, 2018 08:08 AM

    Hi Suresh,

     

    Could you show us the actual step, as below?

     

    Please note, also, that "return true;" will not return anything under JavaScript! The value returned is that of the last assignment processed. This is a "feature" of the language under JSR223 and is not anything to do with DevTest - the same behaviour is true whenever this is used in JSR223 anywhere.



  • 12.  Re: Error in Execute script(JSR-223)

    Posted Jan 03, 2018 11:52 PM

    Hi Dave,

     

    Below are the screen shots for javascript and Benashell scripts.

     

    When i tried with some sample script in javaScript which is throwing an errors where as in Beanshell the same code works fine. I am pasting the code below if image is not visible clearly.

     


    import java.io.*;

    String req=testExec.getStateValue("lisa.Respond.rsp");
    String file=testExec.getStateValue("prop");
    testExec.setStateValue("result",file);

               
     BufferedWriter out = new BufferedWriter(new FileWriter("C:\\LISA_incoming_requests\\"+file+".txt"));
     out.write(req);
    out.close();

     

    Could you please let me if i am doing wrong?

     

    Thanks,

    Suresh N
                
           



  • 13.  Re: Error in Execute script(JSR-223)
    Best Answer

    Posted Jan 04, 2018 04:33 AM

    Hi,

    The simple answer is that you are writing Java code, when you want JavaScript :-)

     

    Try something along the lines of 

     

    req = testExec.getStateValue("lisa.Respond.rsp");
    file = testExec.getStateValue("prop");
    testExec.setStateValue("result",file);

    out = new java.io.BufferedWriter(new java.io.FileWriter("C:\\LISA_incoming_requests\\"+file+".txt"));

    out.write(req);
    out.close();


    /* If you need a return, try

    retval = true; to return true, etc

    Any assignment will do

    */



  • 14.  Re: Error in Execute script(JSR-223)

    Posted Jan 05, 2018 03:32 AM

    Thanks a lot. Its working fine.



  • 15.  Re: Error in Execute script(JSR-223)

    Posted Jan 05, 2018 03:59 AM

    I'm glad it's working for you!

     

    Many people have observed that JavaScript is an unfortunate name, since it is not scripted Java. The name is bound to cause confusion.



  • 16.  Re: Error in Execute script(JSR-223)

    Posted Jan 05, 2018 03:32 AM

    Thanks a lot. Its working fine.