Bug 53576 - docx file Can't read content types part !
Summary: docx file Can't read content types part !
Status: RESOLVED WORKSFORME
Alias: None
Product: POI
Classification: Unclassified
Component: XWPF (show other bugs)
Version: 3.8-FINAL
Hardware: PC All
: P1 critical (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-20 12:31 UTC by Murali Krishna
Modified: 2016-06-12 18:30 UTC (History)
0 users



Attachments
POI XWPFDocument Exception screenshot. (176.87 KB, image/pjpeg)
2012-07-20 12:31 UTC, Murali Krishna
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Murali Krishna 2012-07-20 12:31:46 UTC
Created attachment 29089 [details]
POI XWPFDocument Exception screenshot.

Hi Poi, 

I have downloaded the poi-3.8 version and gathered all the .jar files and used the ikvmc.exe (7.1.4532.2) to generate the .net dll. I have used the below command to generate the poi.dll 

>ikvmc.exe commons-logging-1.1.jar dom4j-1.6.1.jar junit-3.8.1.jar log4j-1.2.13.jar poi-3.8-20120326.jar poi-ooxml-3.8-20120326.jar poi-ooxml-schemas-3.8-20120326.jar poi-scratchpad-3.8-20120326.jar stax-api-1.0.1.jar xmlbeans-2.3.0.jar -out:poi.dll 

After the poi.dll is generated i have reffered the dll in my .net solution and tried the below code to parse a word document(.docx). 

XWPFDocument document = new XWPFDocument(OPCPackage.open(fileName)); 
POIXMLProperties.CoreProperties coreProperties = document.getProperties().getCoreProperties(); 

It is giving me the below exception. 
 at org.apache.poi.openxml4j.opc.internal.ContentTypeManager..ctor(InputStream in, OPCPackage pkg) 
   at org.apache.poi.openxml4j.opc.internal.ZipContentTypeManager..ctor(InputStream in, OPCPackage pkg) 
   at org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl() 
   at org.apache.poi.openxml4j.opc.OPCPackage.getParts() 
   at org.apache.poi.openxml4j.opc.OPCPackage.open(String path, PackageAccess access) 
   at org.apache.poi.openxml4j.opc.OPCPackage.open(String path) 
   at NPOITestProject.Ole2Document.Ole2DocumentMessageParser.ParseFile(String fileName) in D:\Murali\Temp\NPOITestProject\NPOITestProject\Ole2Document\Ole2DocumentMessageParser.cs:line 24 
   at NPOITestProject.Program.Main(String[] args) in D:\Murali\Temp\NPOITestProject\NPOITestProject\Program.cs:line 44 
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) 
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) 
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state) 
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) 
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
   at System.Threading.ThreadHelper.ThreadStart() 

Please explain to me am i doing any thing wrong. Please don't confuse with my project name i mean Ole2DocumentParser.cs i am simply using a word document (.docx) for parsing.

Thanks & Regards, 
N.Murali Krishna.
Comment 1 Nick Burch 2012-07-20 14:05:28 UTC
Could this be .net related? If you run the same code in pure java, does that work?
Comment 2 Murali Krishna 2012-07-23 04:26:54 UTC
Hi Nick,

As i am a .NET devloper i am using the POI as mentioned in the issue description. Since i does not know how to work with Java could you please assign this to some of your team member and ask them whether this work correctly or not.

Thanks & Regards,
N.Murali Krishna.
Comment 3 Yegor Kozlov 2012-07-23 07:05:51 UTC
POI is Java project and we only accept bug reports reproducible in Java, not in .NET and other POI derivatives. 

To run a simple Java test you don't need to be a Java expert, just install JDK, compile and run the following simple code (it is actually what you are running in NET):

class Test {

  public static void main(String[] args){
    XWPFDocument document = new XWPFDocument(OPCPackage.open(args[0])); 
    POIXMLProperties.CoreProperties coreProperties =   
      document.getProperties().getCoreProperties(); 
  }
}

If you still can reproduce the problem, please upload a sample .docx file so that we reproduce it on our side.
Comment 4 olivier57 2013-02-20 14:27:43 UTC
Hi,

I'm using 3.9 with Eclipse Juno to read Excel files and get the same problem. It works with Eclipse but not in jar files in the Appian Environment.


fileName="C:\\myfold\\test2.xlsx";
log("file " + fileName );
File file = new File(fileName);
OPCPackage opcPackage;
XSSFWorkbook myWorkbook = null;
opcPackage = OPCPackage.open(file);
myWorkbook=new XSSFWorkbook(opcPackage); <== Exception
opcPackage.close();


org.apache.poi.openxml4j.exceptions.InvalidFormatException: Can't read content types part !
	at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.<init>(ContentTypeManager.java:107)
	at org.apache.poi.openxml4j.opc.internal.ZipContentTypeManager.<init>(ZipContentTypeManager.java:56)
	at org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:167)
	at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:662)
	at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:248)
	at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:200)
	at com.solypse.etde.SolImportExcel.ReadFile(SolImportExcel.java:186)
	at com.solypse.etde.SolImportExcel.run(SolImportExcel.java:104)
Comment 5 Dominik Stadler 2016-06-12 18:30:28 UTC
Without a sample we cannot do much about this here, please reopen this bug with a sample-file if this is still a problem for you with a recent version of POI.