Forum Discussion

PavithraR's avatar
PavithraR
Occasional Contributor
6 years ago

java jar file error when executing Groovy scripts

Hi,

 

We are trying to generate the Customized test Reports using the Groovy Scripts.

 

But we are getting the java jar file error. We have tried downloading the jar files and tried to executed but the same issue exists.

 

Could you please help me on this issue?

 

Regards,

Pavithra

 

 

 

14 Replies

  • groovyguy's avatar
    groovyguy
    Champion Level 1

    You may want to provide more details. Most helpful would be the groovy script you are trying to use and the error you are receiving. Without that, it is very hard to figure out what the problem may be.

  • PavithraR's avatar
    PavithraR
    Occasional Contributor

    Hi,

     

    Below is the Groovy Script:

     

    import java.text.Format;
    import java.text.SimpleDateFormat;

    import org.apache.poi.xssf.usermodel.XSSFWorkbook;
    import org.apache.poi.xssf.usermodel.XSSFSheet;
    import org.apache.poi.ss.usermodel.Row;
    import org.apache.poi.ss.usermodel.Cell;
    import org.apache.poi.ss.usermodel.CellStyle;
    import org.apache.poi.ss.usermodel.IndexedColors;
    import org.apache.poi.ss.usermodel.FillPatternType;
    import org.apache.poi.ss.usermodel.Font;
    import org.apache.poi.ss.usermodel.HorizontalAlignment
    import org.apache.poi.ss.usermodel.BorderStyle;

    import java.text.Format;
    import java.text.SimpleDateFormat;

    import org.apache.poi.xssf.usermodel.XSSFWorkbook;
    import org.apache.poi.xssf.usermodel.XSSFSheet;
    import org.apache.poi.ss.usermodel.Row;
    import org.apache.poi.ss.usermodel.Cell;
    import org.apache.poi.ss.usermodel.CellStyle;
    import org.apache.poi.ss.usermodel.IndexedColors;
    import org.apache.poi.ss.usermodel.FillPatternType;
    import org.apache.poi.ss.usermodel.Font;
    import org.apache.poi.ss.usermodel.HorizontalAlignment
    import org.apache.poi.ss.usermodel.BorderStyle;

    import com.eviware.soapui.impl.wsdl.support.assertions.*

    def resultPath = context.expand('${#Global# ResultPath}');
    def currTimeStamp = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(new Date());
    int rowNo = 0;

    XSSFWorkbook workbook = new XSSFWorkbook();
    XSSFSheet sheet = workbook.createSheet("Execution_Results");
    Row row = sheet.createRow(rowNo++);

    row.createCell(0).setCellValue("ProjectName");
    row.createCell(1).setCellValue("TestSuite");
    row.createCell(2).setCellValue("TestCase");
    row.createCell(3).setCellValue("StatusName");
    row.createCell(4).setCellValue("TimeStamp");


    for (project in com.eviware.soapui.SoapUI.workspace.projectList) {
                    if (project.name != testRunner.testCase.testSuite.project.name) {
                                    for (testSuite in project.getTestSuiteList()) {
                                                    for (testCase in testSuite.getTestCaseList()) {
                                                                    for (testStep in testCase.getTestStepList()) {
                                                                                    stepResult = testStep.run(testRunner, context);
                                                                                    Date date = new Date(stepResult.getTimeStamp());
                                                                                    Format format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");                                                                               
                                                                                   // status = testStep.testRequest.getResponse().getResponseHeaders().get("#status_code#");                                                                            
                                                                                    timeStamp = format.format(date);
                                                                                    if (stepResult == null) {
                                                                                                    respData = "No response received";
                                                                                    } else {
                                                                                                    respData = stepResult;
                                                                                    }
                                                                                    timeTaken = stepResult.getTimeTaken() + " ms";
                                                                                   
                                                                                    int colNo = 0;
                                                                                    row = sheet.createRow(rowNo++);
                                                                                    row.createCell(colNo++).setCellValue(project.name);
                                                                                    row.createCell(colNo++).setCellValue(testSuite.name);
                                                                                    row.createCell(colNo++).setCellValue(testCase.name);
                                                                                    row.createCell(colNo++).setCellValue(status.name);                                                                            
                                                                                    row.createCell(colNo++).setCellValue(timeStamp);
                                                                                    //log.info testStep.testRequest.getResponse().getResponseHeaders();
                                                                                    //log.info testStep.testRequest.getResponse().getResponseHeaders().get("#status#");
                                                                    }
                                                    }
                                    }
                    }

    try {
                    FileOutputStream fos = new FileOutputStream("D:/"+Filename.xlsx);
                    workbook.write(fos);
                    workbook.close();
    }
    catch (Exception e) {
                    log.info (e.printStackTrace());
    }

     

     

    Regards,

    Pavithra R

    • groovyguy's avatar
      groovyguy
      Champion Level 1

      What error message are you getting? Does this rely on any other external JAR files to be loaded into ReadyAPI? 

      • PavithraR's avatar
        PavithraR
        Occasional Contributor

        Attached Error Message i received.

         

        Can you please help me to get the below .jar files ?

         

        Jars Required:

        poi-3.17

        poi-ooxml-3.17

        poi-ooxml-schemas-3.17

        poi-scratchpad-3.17

        commons-collections4-4.1

         

        Regrads,

        Pavithra R