Exception while reading excel data through POI in soapui
Hello,
I reading the data associated to web service from excel using third party API(apache POI). I executed the script the groovy console and it worked fine. But when I execute in SOAP UI groovy step, getting following error:
- ERROR:org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
- Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.poi.POIXMLTypeLoader
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
class ExcelReader {
public XSSFWorkbook workbook = null;
public XSSFSheet sheet = null;
public XSSFRow row1;
public int rowcount;
public String testplanpath;
def readRowCount(String FilePath) {
def rowCount
def path
path = FilePath;
InputStream inputStream = new FileInputStream(path);
workbook = new XSSFWorkbook(inputStream);
sheet = workbook.getSheet("Sheet1");
rowCount= (sheet.getLastRowNum() - sheet.getFirstRowNum() + 1);
rowCount;
}
}
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def myTestCase = context.testCase
def Tpath
def rcount
Tpath="D:\\POC\\API Testing\\TestPlans\\Testplan3.xlsx"
ExcelReader excelReader = new ExcelReader();
rcount = excelReader.readRowCount(Tpath);
log.info "row count is : $rows"
Please find the attach detailed error log.