【问题标题】:Getting the follwoing Error "Typed variable declaration : Class: Workbook not found in namespace"收到以下错误“类型变量声明:类:在命名空间中找不到工作簿”
【发布时间】:2019-01-24 07:14:49
【问题描述】:

我收到以下错误,

2019-01-24 12:11:27,579 ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import org.apache.jmeter.threads.JMeterVariables; import org.apache.poi.ss.userm . . . '' : Typed variable declaration : Class: Workbook not found in namespace.
2019-01-24 12:11:27,579 WARN o.a.j.e.BeanShellPostProcessor: Problem in BeanShell script: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval  Sourced file: inline evaluation of: ``import org.apache.jmeter.threads.JMeterVariables; import org.apache.poi.ss.userm . . . '' : Typed variable declaration : Class: Workbook not found in namespace

我正在尝试执行以下代码

    import org.apache.jmeter.threads.JMeterVariables;
    import org.apache.poi.ss.usermodel.Cell;
    import org.apache.poi.ss.usermodel.Row;
    import org.apache.poi.ss.usermodel.Sheet;
    import org.apache.poi.ss.usermodel.Workbook;
    import org.apache.poi.xssf.usermodel.XSSFWorkbook;
    import java.io.File;
    import java.io.FileInputStream;

    log.info("before");
    FileInputStream excelFile = new FileInputStream(new File("File Path"));
    log.info("excelFile");
    Workbook wb = new XSSFWorkbook(excelFile);
    excelFile.close();
    log.info("before3");
    Sheet s = wb.getSheetAt(0);
    //Sheet s = wb.getSheet("Bulk Upload");
    int lines = FileUtils.readLines(new File("File Path")).size(); // get lines count
    //vars.put("lines", String.valueOf(lines)); // store the count into "lines" variable
    int i;
    for(i=0; i<=lines;i++)
    {
    log.info("during");
    Row row = s.getRow(i);
    Cell a1 = row.getCell(0);
    String a1Value = a1.getStringCellValue();
    Cell a2 = row.getCell(1);
    String a2Value = a2.getStringCellValue();
    Cell a3 = row.getCell(2);
    String a3Value = a3.getStringCellValue();
    Cell a4 = row.getCell(3);
    String a4Value = a4.getStringCellValue();
    }
    log.info("after");

请告诉我为什么我会收到此错误以及我应该在哪里进行更正

【问题讨论】:

  • 图书馆的路径是什么?

标签: java regex jmeter beanshell post-processor


【解决方案1】:

这是因为Apache POI JAR 文件未在您的类路径上正确设置。您需要将其添加到您的类路径中。

或者,如果您确定确实在类路径中包含了 JAR 文件,请确保您没有遇到菱形依赖问题并同时使用两个不同的版本。根据this other answer 的类似(尽管不是明显重复)问题,Apache POI 不适用于类路径上的多个版本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-03
    • 2012-08-04
    • 1970-01-01
    相关资源
    最近更新 更多