我无法创建XSSFWorkbook的实例。我的代码失败了:
XSSFWorkbook workbook = new XSSFWorkbook();
这里有例外追踪:
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.getMethod(SchemaTypeLoaderBase.java:73)
at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.<clinit>(SchemaTypeLoaderBase.java:66)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.xmlbeans.XmlBeans.getNoType(XmlBeans.java:856)
at org.apache.xmlbeans.XmlBeans.<clinit>(XmlBeans.java:881)
at org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook$Factory.newInstance(Unknown Source)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.onWorkbookCreate(XSSFWorkbook.java:407)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:219)
at excel.readExcelFile(excel.java:24)
at client.readInputFile(client.java:66)
at client.main(client.java:55)
Caused by: java.lang.NullPointerException
at org.apache.xmlbeans.impl.store.Path.<clinit>(Path.java:70)
... 16 more
这里我添加到项目中的罐子:
在阅读了一些信息后,我也尝试添加:
没有效果。可能是什么原因?
更新 问题是我在用户lib中添加了jar并将其添加到项目构建路径中。但是一旦我将它们直接添加到构建传递中 - 错误消失