This simple code: FileInputStream fis = new FileInputStream(filename); document = new XWPFDocument(fis); Using Tiki the mime of the file being attempted: application/vnd.openxmlformats-officedocument.wordprocessingml.document Generates: WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.apache.poi.openxml4j.util.ZipSecureFile$1 (file:/C:/javadev/workspace/poi-3.17/poi-ooxml-3.17.jar) to field java.io.FilterInputStream.in WARNING: Please consider reporting this to the maintainers of org.apache.poi.openxml4j.util.ZipSecureFile$1 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release --> the blocker java.lang.NoSuchMethodException: org.openxmlformats.schemas.wordprocessingml.x2006.main.impl.CTPictureBaseImpl.<init>(org.apache.xmlbeans.SchemaType, boolean) Jar files in use: POI Core came from file:/C:/javadev/workspace/poi-3.17/poi-3.17.jar!/org/apache/poi/poifs/filesystem/POIFSFileSystem.class POI OOXML came from file:/C:/javadev/workspace/poi-3.17/poi-ooxml-3.17.jar!/org/apache/poi/POIXMLDocument.class POI Scratchpad came from file:/C:/javadev/workspace/poi-3.17/poi-scratchpad-3.17.jar!/org/apache/poi/hslf/usermodel/HSLFSlideShow.class I have tried work arounds nothing so far successful. I've tried switching between JVMs 1.7,1.8,1.9. Looking for jar dependencies and tried different files. I am building / running in Eclipse version: Oxygen.2 Release (4.7.2) Build id: 20171218-0600 Libraries on build path: dom4j-2.1.0.jar poi-3.17.jar poi-ooxml-3.17.jar poi-ooxml-schemas-3.17.jar poi-scratchpad-3.17.jar stax-api-1.0.1.jar tika-eval-1.17.jar xmlbeans-2.6.0.jar
Many of the examples for OOXML (XWPFDocument) refer to version 3.9. I gathered all the 3.9 jars, recompiled. Code works.
For the Java 9 warning check [1] and add the addOpens & Co. to your java command. Don't use POI 3.9. This basic example should work - for other cases try the full schema instead of poi-ooxml-schema. [1] http://poi.apache.org/faq.html#faq-N102B0
I was able to get 3.17 to work by adding this to the VM Arguments page of the project: -Xmx1524m --add-modules=java.xml.bind --add-opens=java.xml/com.sun.org.apache.xerces.internal.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED -Duser.language=en -Duser.country=US -Djava9addmods=--add-modules=java.xml.bind -Djavadoc9addmods=--add-modules=java.xml.bind -Djava9addmodsvalue=-Dsun.reflect.debugModuleAccessChecks=true -Djava9addopens1=--add-opens=java.xml/com.sun.org.apache.xerces.internal.util=ALL-UNNAMED -Djava9addopens2=--add-opens=java.base/java.io=ALL-UNNAMED -Djava9addopens3=--add-opens=java.base/java.nio=ALL-UNNAMED -Djava9addopens4=--add-opens=java.base/java.lang=ALL-UNNAMED -Djava9addopens5=--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED -Djava.locale.providers=JRE,CLDR -Dcoverage.enabled=true I also added the ooxml-schemas-1.3.jar to the classpath. If the full version is necessary just to instantiate XWPFDocument, shouldn't it be a little easier to find (or included with the download)?
(In reply to Will Greenway from comment #3) > If the full version is necessary just to instantiate XWPFDocument, shouldn't > it be a little easier to find (or included with the download)? Almost all files should be processable by the standard "minimum" smaller poi-ooxml-schemas jar. However, there's always the odd one that uses something else... Please see this FAQ for more details on the why, the how, and how to get the smaller schemas jar updated to handle your odd file: http://poi.apache.org/faq.html#faq-N10025
*** This bug has been marked as a duplicate of bug 61572 ***
Added triggering file from TIKA-2549 to include CTPictureBaseImpl in our smaller ooxml jar. r1822033
Wanted to add that the file I was reading that caused the issue was docx output from GoogleDocs, which I'd take to be fairly common.
Interesting. Note that the content was still extracted without exception, but the exception was logged. Now we're good -- Java 9 aside. :) Thank you!