poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Branden Visser <mrvis...@gmail.com>
Subject java.lang.NoSuchFieldError: RAW_XML_FILE_HEADER
Date Fri, 15 Jul 2016 00:01:08 GMT
Hello,

First message, so this is bound to be extremely dumb mistake, it
certainly feels that.

(Note SBT and Scala syntax follows)

I've imported "org.apache.poi" % "poi-ooxml" % "3.15-beta2" (only that
dependency).

I have the following code to test:

import org.apache.poi.xwpf.usermodel.XWPFDocument

object XWPFTest {
  def main(args: Array[String]) = {
    val is =  getClass.getResourceAsStream("Word2007.docx")
    val doc = new XWPFDocument(is)
    println(doc)
  }
}

I run it and I get this exception:

[error] Exception in thread "main" java.lang.NoSuchFieldError:
RAW_XML_FILE_HEADER
[error] at org.apache.poi.openxml4j.opc.internal.ZipHelper.verifyZipHeader(ZipHelper.java:179)
[error] at org.apache.poi.openxml4j.opc.internal.ZipHelper.openZipStream(ZipHelper.java:228)
[error] at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:92)
[error] at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:292)
[error] at org.apache.poi.util.PackageHelper.open(PackageHelper.java:37)
[error] at org.apache.poi.xwpf.usermodel.XWPFDocument.<init>(XWPFDocument.java:128)
[error] at XWPFTest$.main(XWPFTest.scala:6)
[error] at XWPFTest.main(XWPFTest.scala)

If I run it with HWPF instead, I get this:

[error] Exception in thread "main"
org.apache.poi.poifs.filesystem.OfficeXmlFileException: The supplied
data appears to be in the Office 2007+ XML. You are calling the part
of POI that deals with OLE2 Office Documents. You need to call a
different part of POI to process this data (eg XSSF instead of HSSF)
[error] at org.apache.poi.poifs.storage.HeaderBlock.<init>(HeaderBlock.java:128)
[error] at org.apache.poi.poifs.storage.HeaderBlock.<init>(HeaderBlock.java:112)
[error] at org.apache.poi.poifs.filesystem.NPOIFSFileSystem.<init>(NPOIFSFileSystem.java:300)
[error] at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:86)
[error] at org.apache.poi.hwpf.HWPFDocumentCore.verifyAndBuildPOIFS(HWPFDocumentCore.java:108)
[error] at org.apache.poi.hwpf.HWPFDocument.<init>(HWPFDocument.java:174)
[error] at XWPFTest$.main(XWPFTest.scala:7)
[error] at XWPFTest.main(XWPFTest.scala)

Which is fair enough. When I open that file up in Microsoft Word it
seems fine. I've attached the file here in case it's relevant, but
this feels more like a coding issue.

Any advice is greatly appreciated.

Cheers,
Branden

Mime
View raw message