cancel
Showing results for 
Search instead for 
Did you mean: 

java jar file error when executing Groovy scripts

Occasional Contributor

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 14
Highlighted
Community Hero

Re: java jar file error when executing Groovy scripts

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.




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
Highlighted
Occasional Contributor

Re: java jar file error when executing Groovy scripts

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

Highlighted
Community Hero

Re: java jar file error when executing Groovy scripts

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




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
Highlighted
Occasional Contributor

Re: java jar file error when executing Groovy scripts

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

Highlighted
Community Hero

Re: java jar file error when executing Groovy scripts

Usually if I need external jars, I check out the MVN repository.  You can find the first one on your list here:

 

https://mvnrepository.com/artifact/org.apache.poi/poi/3.17




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
Highlighted
Occasional Contributor

Re: java jar file error when executing Groovy scripts

Hi Team,

 

I am using the poi jar files of version 3.17.

 

 

Regards,

Pavithra R 

Highlighted
Community Hero

Re: java jar file error when executing Groovy scripts

You already have the JAR file? If so, where did you place it? I believe it has to be in the smartbear\ReadyAPI\BIN folder. Once there, you'll need to close and re-open ReadyAPI for it to be loaded. 




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
Highlighted
Occasional Contributor

Re: java jar file error when executing Groovy scripts

I have placed it in smartbear/ReadyAPI/lib folder and once it done, i have restarted the ready api as well.

 

But its not working.

Highlighted
Community Hero

Re: java jar file error when executing Groovy scripts

I am not sure what the LIB folder is, but I am pretty sure you want to place any external JARs in the EXT folder. 




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
New Here?
Join us and watch the welcome video:
Top Kudoed Authors