我想提到的是,当我使用Java 8时,整个过程运行得非常好。但是,当我在Java 10中尝试相同的过程时,却收到了一条很大的错误消息。
我知道poi 3.17在Java 10中存在问题,但是由于https://bz.apache.org/bugzilla/show_bug.cgi?id=62187-poi 4的开发人员说,现在应该可以在Java 10上运行poi 4,我感到困惑,不知道如何解决我的问题?
Exception in thread "main" java.lang.NoClassDefFoundError: org/w3c/dom/ls/DocumentLS
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1009)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:801)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:699)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:622)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:580)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
at org.apache.xerces.jaxp.DocumentBuilderImpl.<init>(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.setAttribute(Unknown Source)
at org.apache.poi.ooxml.util.DocumentHelper.trySetXercesSecurityManager(DocumentHelper.java:143)
at org.apache.poi.ooxml.util.DocumentHelper.<clinit>(DocumentHelper.java:108)
at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:392)
at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.<init>(ContentTypeManager.java:104)
at org.apache.poi.openxml4j.opc.internal.ZipContentTypeManager.<init>(ZipContentTypeManager.java:54)
at org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:258)
at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:725)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:301)
at org.apache.poi.xslf.usermodel.XMLSlideShow.empty(XMLSlideShow.java:118)
at org.apache.poi.xslf.usermodel.XMLSlideShow.<init>(XMLSlideShow.java:90)
at graphplot.TransferToPowerpoint.BuildPresentation(TransferToPowerpoint.java:202)
at graphplot.GraphPlot.main(GraphPlot.java:139)
Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ls.DocumentLS
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
... 23 more
答案 0 :(得分:0)
您可能会丢失Xerces的传递依赖项之一,至少是xml-apis.jar
,但是您可能还需要http://xerces.apache.org/mirrors.cgi的二进制发行版中还有更多的jar文件。
答案 1 :(得分:0)
我已在我的Gradle设置(build.gradle)中为xercesImpl添加了一个依赖关系,它解决了此问题:
"xerces:xercesImpl:2.12.0",
如果您使用的是Maven,请添加:
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.12.0</version>
</dependency>