Forum Discussion

Bibu_Philip's avatar
Bibu_Philip
New Contributor
2 years ago

Unable to write to excel using groovy script in Test Engine

Hi,

 

I am trying to read/write to an excel file using Groovy script.

It works perfectly in my local ReadyAPI.

However, when I run it on Test Engine, I get the below error:

Error. java.security.AccessControlException: access denied ("java.io.FilePermission" "\Data\XXXXX_E2E_Functional_003.xls" "read")

 

I get this error on the below line of code:

Workbook wb = Workbook.getWorkbook(new File("\\Data\\XXXXX_E2E_Functional_003.xls"));
 
I updated the ReadyAPITestEngine.vmoptions file in Test Engine and added the line at the end: "-Dgroovy.allow.all=true" as mentioned in the documentation link below:
 However, I still get the access denied error.
Appreciate any help or lead into fixing this error.
 
Thanks!
B Philip
  • added -Dgroovy.allow.all=true to ReadyAPITestEngine-service.vmoptions resolves the java.security.AccessControlException: access denied issue

  • tsjeffries's avatar
    tsjeffries
    New Contributor

    added -Dgroovy.allow.all=true to ReadyAPITestEngine-service.vmoptions resolves the java.security.AccessControlException: access denied issue

  • Bibu_Philip's avatar
    Bibu_Philip
    New Contributor

    To add more details, I import jxl library and use the associated classes to read/write to the excel file:

    import jxl.Workbook;
    import jxl.write.Label;
    import jxl.write.WritableSheet;
    import jxl.write.WritableWorkbook;

     

    def project = context.testCase.testSuite.project  //this line is commented in Test Engine, works only with local ReadyAPI
    def project_path = context.expand(project.resourceRoot);  //this line is commented in Test Engine, works only with local ReadyAPI
    def excel_path = project_path + "\\Data\\XXXXX_E2E_Functional_003.xls";  //this line is commented in Test Engine, works only with local ReadyAPI
    Workbook wb = Workbook.getWorkbook(new File(excel_path));  //when running in Test Engine, "excel_path" is replaced with "\\Data\\XXXXX_E2E_Functional_003.xls"
    WritableWorkbook wwb = Workbook.createWorkbook(new File(excel_path), wb);  //when running in Test Engine, "excel_path" is replaced with "\\Data\\XXXXX_E2E_Functional_003.xls"