报错信息 {#%E6%8A%A5%E9%94%99%E4%BF%A1%E6%81%AF}
Exception in thread "main" org.apache.poi.POIXMLException: org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
at org.apache.poi.xslf.usermodel.XMLSlideShow.<init>(XMLSlideShow.java:82)
at org.apache.poi.xslf.usermodel.XMLSlideShow.<init>(XMLSlideShow.java:68)
at demo.ppt.Graph2Ppt.main(Graph2Ppt.java:59)
Caused by: org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
at org.apache.poi.xslf.usermodel.XSLFFactory.createDocumentPart(XSLFFactory.java:66)
at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:403)
at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:155)
at org.apache.poi.xslf.usermodel.XMLSlideShow.<init>(XMLSlideShow.java:80)
... 2 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.apache.poi.xslf.usermodel.XSLFFactory.createDocumentPart(XSLFFactory.java:64)
... 5 more
Caused by: java.lang.ExceptionInInitializerError
at org.openxmlformats.schemas.presentationml.x2006.main.SldMasterDocument$Factory.parse(Unknown Source)
at org.apache.poi.xslf.usermodel.XSLFSlideMaster.<init>(XSLFSlideMaster.java:68)
... 10 more
Caused by: java.lang.NullPointerException
at org.apache.xmlbeans.XmlBeans.typeSystemForClassLoader(XmlBeans.java:769)
at org.openxmlformats.schemas.presentationml.x2006.main.SldMasterDocument.<clinit>(Unknown Source)
... 12 more</code></pre>
### 所有jar包 {#%E6%89%80%E6%9C%89jar%E5%8C%85}
![0268f12443de488c19f0424a609945e5.png](http://static.51tbox.com/static/2024-12-12/col/979d5e59351f1be3eb3e4ee2241f36ed/166f8ea52d4b4f7cac8e000a77627e21.png.jpg)
<br />
### 过程及原因 {#%E8%BF%87%E7%A8%8B%E5%8F%8A%E5%8E%9F%E5%9B%A0}
在网上找到两种原因:jar包冲突、myeclipse的jdk版本和系统版本不匹配。
1.经检查,jdk版本一样。
2.将所有jar包删除,再根据报错信息一一导入,还是出现同样的错误。清理的myeclipse的缓存还是没用。
最后发现实际原因是我重装了系统,项目代码是之前就写好了的。重新导入项目后就出现上文的异常信息。
感觉还是jar包冲突的问题。
<br />
### 解决方法 {#%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95}
新建项目,copy代码,导入jar包。运行,ok。
<br />
### 最后 {#%E6%9C%80%E5%90%8E}
jar包是java操作ppt的,可以参考。
<br />
<br />