Caused by: org.docx4j.openpackaging.exceptions.Docx4JException: Couldn't load file from C:\temp\1.docx
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:180)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:172)
at com.cliu.test.Docx4j.main(Docx4j.java:16)
Caused by: java.io.FileNotFoundException: C:\temp\1.docx (The system cannot find the file specified)
String sFinalFilename = "C:\temp\1.docx";
File objFile = new File(sFinalFilename);
if(!objFile.exists())
{
objFile.createNewFile();
}
sureshbabubv wrote:Hi,
The exception is not related to TIFF type, it is showing that the file that you have specified is not found.
- Code: Select all
Caused by: org.docx4j.openpackaging.exceptions.Docx4JException: Couldn't load file from C:\temp\1.docx
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:180)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:172)
at com.cliu.test.Docx4j.main(Docx4j.java:16)
Caused by: java.io.FileNotFoundException: C:\temp\1.docx (The system cannot find the file specified)
Please add the following code before u r saving the file
- Code: Select all
String sFinalFilename = "C:\temp\1.docx";
File objFile = new File(sFinalFilename);
if(!objFile.exists())
{
objFile.createNewFile();
}
I hope this may solve your problem.
Thanks & Regards,
B.V.Suresh Babu.
String fileName = "/path/to/file";
// before adding the file to imagepart find the mimetype of the image
File file = new File(fileName);
mimeType = mimeTypesMap.getContentType(file);
// assign the content type to the imagepart
BinaryPartAbstractImage imagePart = BinaryPartAbstractImage
.createImagePart(wpPackage, imageBytes);
Inline inline = imagePart.createImageInline(fileNameHint, altText,
id1, id2, false);
ContentType objcontentType = new ContentType(mimeType);
imagePart.setContentType(objcontentType);
sureshbabubv wrote:Hi,
Please try this code
- Code: Select all
String fileName = "/path/to/file";
// before adding the file to imagepart find the mimetype of the image
File file = new File(fileName);
mimeType = mimeTypesMap.getContentType(file);
// assign the content type to the imagepart
BinaryPartAbstractImage imagePart = BinaryPartAbstractImage
.createImagePart(wpPackage, imageBytes);
Inline inline = imagePart.createImageInline(fileNameHint, altText,
id1, id2, false);
ContentType objcontentType = new ContentType(mimeType);
imagePart.setContentType(objcontentType);
I hope this may resolve your issue
Thanks & Regards,
B.V.Suresh Babu.
11.06.12 13:58:27.037 ERROR SaveToZipFile:368 - Part word/media/image1.tif not found!
org.docx4j.openpackaging.exceptions.Docx4JException: Failed to add parts from relationships
at org.docx4j.openpackaging.io.SaveToZipFile.addPartsFromRelationships(SaveToZipFile.java:378)
at org.docx4j.openpackaging.io.SaveToZipFile.save(SaveToZipFile.java:164)
at org.docx4j.openpackaging.io.SaveToZipFile.save(SaveToZipFile.java:105)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.save(WordprocessingMLPackage.java:219)
16983 DEBUG o.d.o.i.Save - For Relationship Id=rId18__1127224101 Source is /, Target is word/media/image6__1.wmf
16983 DEBUG o.d.o.i.Save - Getting part /word/media/image6__1.wmf
16983 DEBUG o.d.o.i.Save - org.docx4j.openpackaging.parts.WordprocessingML.MetafileWmfPart
16983 DEBUG o.d.o.i.Save - .. saving binary stuff
16983 DEBUG o.d.o.i.s.ZipPartStore - /word/media/image6__1.wmf is clean
org.docx4j.openpackaging.exceptions.Docx4JException: Failed to add parts from relationships of /
at org.docx4j.openpackaging.io3.Save.addPartsFromRelationships(Save.java:390)
at org.docx4j.openpackaging.io3.Save.save(Save.java:192)
at org.docx4j.openpackaging.packages.OpcPackage.save(OpcPackage.java:442)
new_rel = /*target_rp*/wmlPackage.getMainDocumentPart()
.addTargetPart(source_part_to_rel, AddPartBehaviour.RENAME_IF_NAME_EXISTS, /*wmlPackage.getContentTypeManager(),*/ source_rel.getId());
//HERE A SHORTCUT IS EVENTUALLY SET THE REST IS EQUAL TO ABOVE
15118 DEBUG o.d.o.i.Save - .. saving binary stuff
15118 DEBUG o.d.o.i.s.ZipPartStore - /word/media/image4.wmf is clean
15119 INFO o.d.o.i.s.ZipPartStore - success writing part: word/media/image4.wmf
15119 DEBUG o.d.o.i.Save - For Relationship Id=rId22 Source is /word/document.xml, Target is embeddings/oleObject8.bin
15119 DEBUG o.d.o.i.Save - Getting part /word/embeddings/oleObject8.bin
15119 DEBUG o.d.o.i.Save - org.docx4j.openpackaging.parts.WordprocessingML.OleObjectBinaryPart
15119 DEBUG o.d.o.i.Save - .. saving binary stuff
15119 DEBUG o.d.o.i.s.ZipPartStore - /word/embeddings/oleObject8.bin is clean
15120 INFO o.d.o.i.s.ZipPartStore - success writing part: word/embeddings/oleObject8.bin
15126 DEBUG o.d.o.i.Save - For Relationship Id=rId18__811960591 Source is /word/document.xml, Target is media/image6__1.wmf
15126 DEBUG o.d.o.i.Save - Getting part /word/media/image6__1.wmf
15127 DEBUG o.d.o.i.Save - org.docx4j.openpackaging.parts.WordprocessingML.MetafileWmfPart
15127 DEBUG o.d.o.i.Save - .. saving binary stuff
15127 DEBUG o.d.o.i.s.ZipPartStore - /word/media/image6__1.wmf is clean
org.docx4j.openpackaging.exceptions.Docx4JException: Failed to add parts from relationships of /
at org.docx4j.openpackaging.io3.Save.addPartsFromRelationships(Save.java:390)
at org.docx4j.openpackaging.io3.Save.save(Save.java:192)
at org.docx4j.openpackaging.packages.OpcPackage.save(OpcPackage.java:442)
at org.docx4j.openpackaging.packages.OpcPackage.save(OpcPackage.java:407)
at aufgaben_db.Global.mergeSourceFileIntoTargetFile(Global.java:3626)
at aufgaben_db.Global.mergeSourceFileIntoTargetFile(Global.java:3210)
at aufgaben_db.Global.joinToFile(Global.java:2635)
at aufgaben_db.Global.joinToFile(Global.java:2497)
at org.apache.jsp.action_draft_005fto_005fsheet_jsp._jspService(action_draft_005fto_005fsheet_jsp.java:241)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
at org.apache.jsp.action_inc_jsp._jspService(action_inc_jsp.java:329)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:213)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.docx4j.openpackaging.exceptions.Docx4JException: Failed to add parts from relationships of /word/document.xml
at org.docx4j.openpackaging.io3.Save.addPartsFromRelationships(Save.java:390)
at org.docx4j.openpackaging.io3.Save.savePart(Save.java:442)
at org.docx4j.openpackaging.io3.Save.addPartsFromRelationships(Save.java:385)
... 52 more
Caused by: org.docx4j.openpackaging.exceptions.Docx4JException: Failed to put binary part
at org.docx4j.openpackaging.io3.stores.ZipPartStore.saveBinaryPart(ZipPartStore.java:398)
at org.docx4j.openpackaging.io3.Save.savePart(Save.java:418)
at org.docx4j.openpackaging.io3.Save.addPartsFromRelationships(Save.java:385)
... 54 more
Caused by: java.io.IOException: part '/word/media/image6__1.wmf' not found
at org.docx4j.openpackaging.io3.stores.ZipPartStore.saveBinaryPart(ZipPartStore.java:361)
... 56 more
Apr 07, 2014 8:06:24 AM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.io.IOException: part '/word/media/image6__1.wmf' not found
at org.docx4j.openpackaging.io3.stores.ZipPartStore.saveBinaryPart(ZipPartStore.java:361)
at org.docx4j.openpackaging.io3.Save.savePart(Save.java:418)
at org.docx4j.openpackaging.io3.Save.addPartsFromRelationships(Save.java:385)
at org.docx4j.openpackaging.io3.Save.savePart(Save.java:442)
at org.docx4j.openpackaging.io3.Save.addPartsFromRelationships(Save.java:385)
at org.docx4j.openpackaging.io3.Save.save(Save.java:192)
at org.docx4j.openpackaging.packages.OpcPackage.save(OpcPackage.java:442)
at org.docx4j.openpackaging.packages.OpcPackage.save(OpcPackage.java:407)
at aufgaben_db.Global.mergeSourceFileIntoTargetFile(Global.java:3626)
at aufgaben_db.Global.mergeSourceFileIntoTargetFile(Global.java:3210)
at aufgaben_db.Global.joinToFile(Global.java:2635)
at aufgaben_db.Global.joinToFile(Global.java:2497)
at org.apache.jsp.action_draft_005fto_005fsheet_jsp._jspService(action_draft_005fto_005fsheet_jsp.java:241)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
at org.apache.jsp.action_inc_jsp._jspService(action_inc_jsp.java:329)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:213)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:722)
Apr 07, 2014 8:06:24 AM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.io.IOException: part '/word/media/image6__1.wmf' not found
at org.docx4j.openpackaging.io3.stores.ZipPartStore.saveBinaryPart(ZipPartStore.java:361)
at org.docx4j.openpackaging.io3.Save.savePart(Save.java:418)
at org.docx4j.openpackaging.io3.Save.addPartsFromRelationships(Save.java:385)
at org.docx4j.openpackaging.io3.Save.savePart(Save.java:442)
at org.docx4j.openpackaging.io3.Save.addPartsFromRelationships(Save.java:385)
at org.docx4j.openpackaging.io3.Save.save(Save.java:192)
at org.docx4j.openpackaging.packages.OpcPackage.save(OpcPackage.java:442)
at org.docx4j.openpackaging.packages.OpcPackage.save(OpcPackage.java:407)
at aufgaben_db.Global.mergeSourceFileIntoTargetFile(Global.java:3626)
at aufgaben_db.Global.mergeSourceFileIntoTargetFile(Global.java:3210)
at aufgaben_db.Global.joinToFile(Global.java:2635)
at aufgaben_db.Global.joinToFile(Global.java:2497)
at org.apache.jsp.action_draft_005fto_005fsheet_jsp._jspService(action_draft_005fto_005fsheet_jsp.java:241)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
at org.apache.jsp.action_inc_jsp._jspService(action_inc_jsp.java:329)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:213)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:722)
Apr 07, 2014 8:06:24 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.io.IOException: part '/word/media/image6__1.wmf' not found
at org.docx4j.openpackaging.io3.stores.ZipPartStore.saveBinaryPart(ZipPartStore.java:361)
at org.docx4j.openpackaging.io3.Save.savePart(Save.java:418)
at org.docx4j.openpackaging.io3.Save.addPartsFromRelationships(Save.java:385)
at org.docx4j.openpackaging.io3.Save.savePart(Save.java:442)
at org.docx4j.openpackaging.io3.Save.addPartsFromRelationships(Save.java:385)
at org.docx4j.openpackaging.io3.Save.save(Save.java:192)
at org.docx4j.openpackaging.packages.OpcPackage.save(OpcPackage.java:442)
at org.docx4j.openpackaging.packages.OpcPackage.save(OpcPackage.java:407)
at aufgaben_db.Global.mergeSourceFileIntoTargetFile(Global.java:3626)
at aufgaben_db.Global.mergeSourceFileIntoTargetFile(Global.java:3210)
at aufgaben_db.Global.joinToFile(Global.java:2635)
at aufgaben_db.Global.joinToFile(Global.java:2497)
at org.apache.jsp.action_draft_005fto_005fsheet_jsp._jspService(action_draft_005fto_005fsheet_jsp.java:241)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
at org.apache.jsp.action_inc_jsp._jspService(action_inc_jsp.java:329)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:213)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:722)
... up to come, eclipse just crashed
RelationshipsPart target_rp = target_allRelationshipsParts.get(allRelationshipsParts_index);
RelationshipsPart source_rp = source_allRelationshipsParts.get(allRelationshipsParts_index);
for (Relationship source_rel : source_rp.getRelationships().getRelationship() ) {
Part source_part_to_rel = source_rp.getPart(source_rel);
if (source_part_to_rel == null) {
if (target_rp.getPart(source_rel.getTarget()) == null) {
// => this target does not exist anywhere.
continue;
}
// is it one of those relationships where we reuse the existing? Because then we continue so that the source content that might use it, can use it. If we skipped instead, then the relationship might not get into target. But it should. Though it is strange that there was no corresponding target part then. Perhaps it should really be skipped. Or this is an auto-repair functionality?
else if (!source_rel.getType().equals(Namespaces.IMAGE)) {//TODO put into a list to not have to update at more than one place.
source_part_to_rel = target_rp.getPart(source_rel.getTarget());
}
//else skip as IMAGES would be copied and we wish to avoid redundant content (in this case double images).
}
String source_rel_rId_old = source_rel.getId();
setUniqueRelId(source_rel, wmlPackage /*where it should be unique*/);
// we take over images and rename those if they already exist in the target (TODO only if content equal, resue existing):
Relationship new_rel = null; //<-- instead of that we could insert source rel prior to adding the Part. then the existing would be reused but the content types are not updated and perhaps other dangerous things.
if (source_rel.getType().equals(Namespaces.IMAGE)) {
source_part_to_rel.setPackage(source_wMLPac);//<-- very important! for operating on the correct package when adding/removing the part.
// Does the part name already exist in the target package?
if (wmlPackage.getParts().getParts().get(source_part_to_rel.getPartName()) != null) {
/* as we wish to add this part without overwriting one with the same pathTo, i.e.partName,
we check if the partName is given already (as this is the Map's key, so it's unique.)
=> change if required. update all references (relationships).
*/
int loopCountLimit = 100;
int number = 0;
String[] str_parts = source_part_to_rel.getPartName().getName().split("[.]");
String partName_old_base = str_parts[0];
PartName partName_old = source_part_to_rel.getPartName();
PartName partName_new = partName_old; //start with the old one.
while (++number < loopCountLimit
//&& wmlPackage.getParts().getParts().containsKey(source_part_to_rel.getPartName())) {
&& wmlPackage.getParts().getParts().get(partName_new) != null) {
String partName_new_str;
partName_new_str = partName_old_base + "__" + number;
String pointAfterFirstRound = "";
for (String str_part : str_parts) {
// skip the first entry as this is treated above already.
if (!pointAfterFirstRound.isEmpty()) {
partName_new_str += pointAfterFirstRound + str_part;
}
pointAfterFirstRound = ".";
}
partName_new = new PartName(partName_new_str);
}
// still no unique name? => repeat with random number
number = 0;
while (++number < loopCountLimit
//&& wmlPackage.getParts().getParts().containsKey(source_part.getPartName())) {
&& wmlPackage.getParts().getParts().get(partName_new) != null) {
String partName_new_str;
partName_new_str = partName_old_base + "__" + ((long)(Math.random() * 1000000));
String pointAfterFirstRound = "";
for (String str_part : str_parts) {
// skip the first entry as this is treated above already.
if (!pointAfterFirstRound.isEmpty()) {
partName_new_str += pointAfterFirstRound + str_part;
}
pointAfterFirstRound = ".";
}
partName_new = new PartName(partName_new_str);
}
// now we hopefully have a unique partname. => rename the part:
source_part_to_rel.setPartName(partName_new);
}
//else the source part name is already unique in the target package. No rename required.
// Add the source part:
// takes care of part name uniqueness renaming already.
new_rel = /*target_rp*/wmlPackage.getMainDocumentPart().addTargetPart(source_part_to_rel, AddPartBehaviour.RENAME_IF_NAME_EXISTS, /*wmlPackage.getContentTypeManager(),*/ source_rel.getId());
}
// for others we prefer reusing existing doubles:
else {//if (source_rel.getType().equals(Namespaces.STYLES)) {
// takes care of part name uniqueness renaming already:
new_rel = /*target_rp*/wmlPackage.getMainDocumentPart().addTargetPart(source_part_to_rel, AddPartBehaviour.REUSE_EXISTING, /*wmlPackage.getContentTypeManager(),*/ source_rel.getId());
// now as the part could have been reused, fetch the part:
Part old_source_part_to_rel = source_part_to_rel;
source_part_to_rel = wmlPackage.getMainDocumentPart().getRelationshipsPart().getPart(new_rel);
}
source_part_to_rel.setPackage(wmlPackage); //<-- always the target. not the source one.
// otherwise this things happen already in addPart which calls loadPart (only if not REUSING EXISTING).
// new relationship was already inserted into the relationshipPart.
//target_rp.addRelationship(new_rel); new_rel.setParent(target_rp);
}
}
/word/media/image6.wmf --> /word/media/image6__1.wmf
} else if (this.sourcePartStore==this) {
// Just use the ByteArray
log.debug(part.getPartName() + " is clean" );
ByteArray byteArray = partByteArrays.get(
part.getPartName().getName().substring(1) );
if (byteArray == null) throw new IOException("part '" + part.getPartName() + "' not found");
bytes = byteArray.getBytes();
}
partByteArrays.put(partName, part.getBytes())
if (part instanceof BinaryPart ) {
log.debug(".. saving binary stuff" );
p.getTargetPartStore().saveBinaryPart( part );
}
target_wmlPackage.getTargetPartStore()
if (source_wMLPac.getTargetPartStore() instanceof ZipPartStore) {
if (!((ZipPartStore) source_wMLPac.getTargetPartStore()).partExists(partName_new.getName())) {
if (((ZipPartStore) source_wMLPac.getTargetPartStore()).partExists(partName_old.getName())) {
// then the old at least exists. Copy it over.
((ZipPartStore) source_wMLPac.getTargetPartStore()).partByteArray.put(
partName_new.getName()
,
((ZipPartStore) source_wMLPac.getTargetPartStore()).partByteArray.get(partName_old.getName())
);
}
}
}
/**
* Store buffer thru soft reference so it could be
* unloaded by the java vm if free memory is low.
*/
private Reference<ByteBuffer> bbRef = null;
/**
* @since 3.0
*/
public boolean isLoaded() {
if (this.bb != null) {
return true;
}
return (this.bbRef != null);
}
if (((BinaryPart)part).isLoaded() ) {
bytes = ((BinaryPart)part).getBytes();
} else if (this.sourcePartStore==this) {
// Just use the ByteArray
log.debug(part.getPartName() + " is clean" );
ByteArray byteArray = partByteArrays.get(
part.getPartName().getName().substring(1) );
if (byteArray == null) throw new IOException("part '" + part.getPartName() + "' not found");
zos.write( byteArray.getBytes() );
}
Users browsing this forum: No registered users and 37 guests