In the class org.apache.poi.openxml4j.opc.internal.ContentTypeManager the method addContentType(PackagePartName,String) doesn't authorized to register the same contentType string for two different package part name if those part name have different extension.
Can you provide a code snippet to avoid confusion? Would you be able to try the latest POI version - 4.0.0?
Code that reproduce : File testFile = new File("test.zip"); OPCPackage mainPkg = OPCPackage.openOrCreate(testFile); PackagePartName firstPartName = PackagingURIHelper.createPartName("/dummy/text.txt"); PackagePart firstPkg = mainPkg.createPart(firstPartName, "text/plain"); OutputStreamWriter osW = new OutputStreamWriter(firstPkg.getOutputStream(), "UTF8"); osW.append("FOO"); osW.flush(); osW.close(); firstPkg.flush(); firstPkg.close(); PackagePartName secondPartName = PackagingURIHelper.createPartName("/dummy/text.properties"); PackagePart secondPkg = mainPkg.createPart(secondPartName, "text/plain"); osW = new OutputStreamWriter(secondPkg.getOutputStream(), "UTF8"); osW.append("BAR FOO"); osW.flush(); osW.close(); firstPkg.flush(); firstPkg.close(); mainPkg.close(); mainPkg = OPCPackage.openOrCreate(testFile); And yes it failed also with 4.0.
Exception in thread "main" org.apache.poi.openxml4j.exceptions.InvalidFormatException: The part /dummy/text.properties does not have any content type ! Rule: Package require content types when retrieving a part from a package. [M.1.14] at org.apache.poi.openxml4j.opc.ZipPackage$EntryTriple.register(ZipPackage.java:325) at org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:293) at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:725) at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:238) at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:167) at org.apache.poi.openxml4j.opc.OPCPackage.openOrCreate(OPCPackage.java:322) at test.Main.main(Main.java:59)
I quickly tried to reproduce this, but could not on latest trunk. Which operating system are you running this on? BTW in your sample, you do not flush/close secondPkg, maybe that is related?
*** Bug 62718 has been marked as a duplicate of this bug. ***
Could not reproduce and no reply for a long time, thus closing for now, please repoen with more information if this is still a problem for you.