我有一个Lotus notes hava代理,可以在Apache POI的帮助下从Lotus Notes文档中附带的powerpoint文件中检索幻灯片数据。有时它有效,有时它不起作用,如果它不起作用,这里是常见的错误堆栈跟踪。
Java控制台:
Start
blahblahblah.pptx
File has pptx extension
Reading embedded object...
Read existing presentation
org.apache.poi.POIXMLException: org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
at org.apache.poi.xslf.usermodel.XMLSlideShow.<init>(XMLSlideShow.java:91)
at org.apache.poi.xslf.usermodel.XMLSlideShow.<init>(XMLSlideShow.java:96)
at JavaAgent.NotesMain(JavaAgent.java:98)
at lotus.domino.AgentBase.runNotes(Unknown Source)
at lotus.domino.NotesThread.run(Unknown Source)
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:426)
at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:155)
at org.apache.poi.xslf.usermodel.XMLSlideShow.<init>(XMLSlideShow.java:89)
... 4 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:56)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:39)
at java.lang.reflect.Constructor.newInstance(Constructor.java:527)
at org.apache.poi.xslf.usermodel.XSLFFactory.createDocumentPart(XSLFFactory.java:64)
... 7 more
Caused by: java.lang.OutOfMemoryError: Java heap space
at org.apache.xmlbeans.impl.store.Cur.createElementXobj(Cur.java:257)
at org.apache.xmlbeans.impl.store.Cur$CurLoadContext.startElement(Cur.java:2992)
at org.apache.xmlbeans.impl.store.Locale$SaxHandler.startElement(Locale.java:3198)
at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.reportStartTag(Piccolo.java:1082)
at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseAttributesNS(PiccoloLexer.java:1802)
at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseOpenTagNS(PiccoloLexer.java:1521)
at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseTagNS(PiccoloLexer.java:1362)
at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.yylex(PiccoloLexer.java:4678)
at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.yylex(Piccolo.java:1290)
at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.yyparse(Piccolo.java:1400)
at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:714)
at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:3439)
at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1270)
at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1257)
at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:345)
at org.openxmlformats.schemas.presentationml.x2006.main.SldDocument$Factory.parse(Unknown Source)
at org.apache.poi.xslf.usermodel.XSLFSlide.<init>(XSLFSlide.java:67)
... 12 more
Next Document
Finished scanning reports
代码段:
if(extension.equalsIgnoreCase("pptx")) { // If file is 2007+ powerpoint file
System.out.println("File has pptx extension");
try {
System.out.println("Reading embedded object...");
IS = att.getInputStream(); //EmbeddedObject att = (EmbeddedObject) rtnav.getElement();
System.out.println("Read existing presentation");
XMLSlideShow pptxshow = new XMLSlideShow(IS);
System.out.println("Getting slides from file...");
如您所见,XMLSlideShow pptxshow = new XMLSlideShow(IS)
它读取的附件只有1155 KB。
答案 0 :(得分:2)
宣传回答评论......
您的例外中的关键位是
引起:java.lang.OutOfMemoryError:Java堆空间
这似乎是由您使用默认的JVM堆大小引起的,并且该默认值非常小
只是提高最大的Java堆大小,然后就可以了!