As the title says, I'm having a weird issue at the moment with the production server. While the system and the tool worked fine until recently, somehow it broke. My best guess is just that something went odd during initialization so a restart might be everything it needs, but I don't want to tose a dice everytime we have to restart for whatever reason. So right now as out app has this issue, I want to try and add/remove anything that would trhow this error.
The error happens just at the end of the convertion, in the toHTML method. The full trace is as follow, but at the end, it happens on line 202 of ObfuscatedFontPart.deleteEmbeddedFontTempFiles.
- Code: Select all
2021-03-17 09:42:44,641 ERROR org.zkoss.bind.impl.ParamCall -
org.docx4j.openpackaging.exceptions.Docx4JException: Exception exporting package
at org.docx4j.convert.out.common.AbstractExporter.export(AbstractExporter.java:106)
at org.docx4j.Docx4J.toHTML(Docx4J.java:919)
at mx.com.ficachi.fch_legal.controllers.main.OpinionesVM.importarDocx(OpinionesVM.java:293)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.zkoss.bind.impl.ParamCall.call(ParamCall.java:158)
at org.zkoss.bind.impl.BinderImpl.handleNotifyChange(BinderImpl.java:1911)
at org.zkoss.bind.impl.BinderImpl.doExecute(BinderImpl.java:2080)
at org.zkoss.bind.impl.BinderImpl.doCommand(BinderImpl.java:1806)
at org.zkoss.bind.impl.BinderImpl.access$1300(BinderImpl.java:137)
at org.zkoss.bind.impl.BinderImpl$CommandEventListener.onEvent0(BinderImpl.java:1647)
at org.zkoss.bind.impl.BinderImpl$CommandEventListener.onEvent(BinderImpl.java:1600)
at org.zkoss.zk.ui.AbstractComponent.onEvent(AbstractComponent.java:3184)
at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:3154)
at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:3096)
at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:138)
at org.zkoss.zk.ui.impl.UiEngineImpl.processEvent(UiEngineImpl.java:1890)
at org.zkoss.zk.ui.impl.UiEngineImpl.process(UiEngineImpl.java:1662)
at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1329)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:570)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:450)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:458)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:317)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:155)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException: null
at org.docx4j.openpackaging.parts.WordprocessingML.ObfuscatedFontPart.deleteEmbeddedFontTempFiles(ObfuscatedFontPart.java:202)
at org.docx4j.openpackaging.parts.WordprocessingML.FontTablePart.deleteEmbeddedFontTempFiles(FontTablePart.java:176)
at org.docx4j.convert.out.common.AbstractExporter.export(AbstractExporter.java:90)
... 81 common frames omitted
I find this VERY odd. As I said before, this tool had been working for months and this is the first time it throws this error. I havent updated my related dependencies not changed the code. The trace tells me it might be a permissions related issue or a path issue (Our server is running Ubuntu 18.04, while most of our dev machines are all Windows 10). All the changes made during updates are made with the same user on our server AFAIK.
Something else I have to add is that TONS of warnings about no physical fonts found. Our server only has dejavu installed (Although I just added Open Sans) so I guess is expected. I understand installing windows font might help with those, but we don't need more fonts really. The following is the log of this (Before installing OpenSans):
- Code: Select all
2021-03-17 15:16:12,040 INFO o.docx4j.openpackaging.io3.Load3 - Instantiated package of type org.docx4j.openpackaging.packages.WordprocessingMLPackage
2021-03-17 15:16:12,041 INFO o.docx4j.openpackaging.io3.Load3 - package read; elapsed time: 4 ms
2021-03-17 15:16:12,041 WARN o.d.fonts.IdentityPlusMapper - WARNING! SubstituterWindowsPlatformImpl works best on Windows. To get good results on other platforms, you'll probably need to have installed Windows fonts.
2021-03-17 15:16:12,043 WARN org.docx4j.fonts.PhysicalFonts - Overwriting existing physicalFontMap entry: dejavu serif bold italic
2021-03-17 15:16:12,043 WARN org.docx4j.fonts.PhysicalFonts - Overwriting existing physicalFontMap entry: dejavu sans condensed bold
2021-03-17 15:16:12,043 WARN org.docx4j.fonts.PhysicalFonts - Overwriting existing physicalFontMap entry: dejavu sans
2021-03-17 15:16:12,043 WARN org.docx4j.fonts.PhysicalFonts - Overwriting existing physicalFontMap entry: dejavu sans bold oblique
2021-03-17 15:16:12,043 WARN org.docx4j.fonts.PhysicalFonts - Overwriting existing physicalFontMap entry: dejavu sans extralight
2021-03-17 15:16:12,043 WARN org.docx4j.fonts.PhysicalFonts - Overwriting existing physicalFontMap entry: dejavu sans condensed
2021-03-17 15:16:12,043 WARN org.docx4j.fonts.PhysicalFonts - Overwriting existing physicalFontMap entry: dejavu sans bold
2021-03-17 15:16:12,044 WARN org.docx4j.fonts.PhysicalFonts - Overwriting existing physicalFontMap entry: dejavu sans mono
2021-03-17 15:16:12,044 WARN org.docx4j.fonts.PhysicalFonts - Overwriting existing physicalFontMap entry: dejavu serif condensed italic
2021-03-17 15:16:12,044 WARN org.docx4j.fonts.PhysicalFonts - Overwriting existing physicalFontMap entry: dejavu serif condensed
2021-03-17 15:16:12,044 WARN org.docx4j.fonts.PhysicalFonts - Overwriting existing physicalFontMap entry: dejavu serif italic
2021-03-17 15:16:12,044 WARN org.docx4j.fonts.PhysicalFonts - Overwriting existing physicalFontMap entry: dejavu sans oblique
2021-03-17 15:16:12,044 WARN org.docx4j.fonts.PhysicalFonts - Overwriting existing physicalFontMap entry: dejavu sans condensed bold oblique
2021-03-17 15:16:12,044 WARN org.docx4j.fonts.PhysicalFonts - Overwriting existing physicalFontMap entry: dejavu serif condensed bold italic
2021-03-17 15:16:12,044 WARN org.docx4j.fonts.PhysicalFonts - Overwriting existing physicalFontMap entry: dejavu sans mono oblique
2021-03-17 15:16:12,044 WARN org.docx4j.fonts.PhysicalFonts - Overwriting existing physicalFontMap entry: dejavumathtexgyre-regular
2021-03-17 15:16:12,044 WARN org.docx4j.fonts.PhysicalFonts - Overwriting existing physicalFontMap entry: dejavu serif condensed bold
2021-03-17 15:16:12,044 WARN org.docx4j.fonts.PhysicalFonts - Overwriting existing physicalFontMap entry: dejavu sans condensed oblique
2021-03-17 15:16:12,045 WARN org.docx4j.fonts.PhysicalFonts - Overwriting existing physicalFontMap entry: dejavu serif bold
2021-03-17 15:16:12,045 WARN org.docx4j.fonts.PhysicalFonts - Overwriting existing physicalFontMap entry: dejavu sans mono bold oblique
2021-03-17 15:16:12,045 WARN org.docx4j.fonts.PhysicalFonts - Overwriting existing physicalFontMap entry: dejavu sans mono bold
2021-03-17 15:16:12,045 WARN org.docx4j.fonts.PhysicalFonts - Overwriting existing physicalFontMap entry: dejavu serif
2021-03-17 15:16:12,072 INFO org.docx4j.fonts.RunFontSelector - rPrDefault/rFonts referenced Courier
2021-03-17 15:16:12,072 WARN org.docx4j.fonts.RunFontSelector - Font 'Courier' is not mapped to a physical font.
2021-03-17 15:16:12,183 INFO o.d.o.p.W.FontTablePart - Writing temp embedded fonts 1616015772183
2021-03-17 15:16:12,183 WARN o.d.fonts.IdentityPlusMapper - - - No physical font for: Courier New
2021-03-17 15:16:12,183 WARN o.d.fonts.IdentityPlusMapper - - - No physical font for: Symbol
2021-03-17 15:16:12,183 WARN o.d.fonts.IdentityPlusMapper - - - No physical font for: Times New Roman
2021-03-17 15:16:12,183 WARN o.d.fonts.IdentityPlusMapper - - - No physical font for: Arial
2021-03-17 15:16:12,183 WARN o.d.fonts.IdentityPlusMapper - - - No physical font for: Wingdings
2021-03-17 15:16:12,183 WARN o.d.fonts.IdentityPlusMapper - - - No physical font for: Courier
2021-03-17 15:16:12,184 INFO o.d.o.parts.DocPropsExtendedPart - unmarshalling org.docx4j.openpackaging.parts.DocPropsExtendedPart
2021-03-17 15:16:12,185 INFO o.d.o.parts.DocPropsCorePart - unmarshalling org.docx4j.openpackaging.parts.DocPropsCorePart
2021-03-17 15:16:12,212 INFO org.docx4j.fonts.RunFontSelector - rPrDefault/rFonts referenced Courier
2021-03-17 15:16:12,212 WARN org.docx4j.fonts.RunFontSelector - Font 'Courier' is not mapped to a physical font.
2021-03-17 15:16:12,313 INFO o.d.o.p.W.FontTablePart - Writing temp embedded fonts 1616015772313
2021-03-17 15:16:12,322 INFO o.d.c.o.c.p.FieldsCombiner - starting
2021-03-17 15:16:12,347 INFO org.docx4j.fonts.RunFontSelector - rPrDefault/rFonts referenced Courier
2021-03-17 15:16:12,347 WARN org.docx4j.fonts.RunFontSelector - Font 'Courier' is not mapped to a physical font.
2021-03-17 15:16:12,347 WARN org.docx4j.fonts.RunFontSelector - Courier is not mapped!
2021-03-17 15:16:12,357 INFO org.docx4j.XmlUtils - Using org.docx4j.org.apache.xalan.transformer.TransformerImpl
2021-03-17 15:16:12,358 WARN org.docx4j.XmlUtils - parameter 'fontMapper' was null.
2021-03-17 15:16:12,358 INFO o.d.c.o.c.AbstractConversionContext - /pkg:package
2021-03-17 15:16:12,359 WARN o.d.c.out.html.HtmlCssHelper - ! null rPr for character style Fuentedeprrafopredeter
2021-03-17 15:16:12,359 WARN o.d.c.out.html.HtmlCssHelper - ! null rPr for character style Nmerodepgina
2021-03-17 15:16:12,362 WARN org.docx4j.fonts.RunFontSelector - Font 'Times New Roman' is not mapped to a physical font.
2021-03-17 15:16:12,362 INFO org.docx4j.fonts.RunFontSelector - No physical font for Times New Roman
2021-03-17 15:16:12,364 WARN org.docx4j.fonts.RunFontSelector - Font 'Times New Roman' is not mapped to a physical font.
2021-03-17 15:16:12,364 INFO org.docx4j.fonts.RunFontSelector - No physical font for Times New Roman
2021-03-17 15:16:12,365 WARN org.docx4j.fonts.RunFontSelector - Font 'Times New Roman' is not mapped to a physical font.
2021-03-17 15:16:12,365 INFO org.docx4j.fonts.RunFontSelector - No physical font for Times New Roman
2021-03-17 15:16:12,366 WARN org.docx4j.fonts.RunFontSelector - Font 'Courier' is not mapped to a physical font.
2021-03-17 15:16:12,366 INFO org.docx4j.fonts.RunFontSelector - No physical font for Courier
2021-03-17 15:16:12,379 WARN org.docx4j.fonts.RunFontSelector - Font 'Times New Roman' is not mapped to a physical font.
2021-03-17 15:16:12,379 INFO org.docx4j.fonts.RunFontSelector - No physical font for Times New Roman
2021-03-17 15:16:12,380 WARN org.docx4j.fonts.RunFontSelector - Font 'Arial' is not mapped to a physical font.
2021-03-17 15:16:12,380 INFO org.docx4j.fonts.RunFontSelector - No physical font for Arial
2021-03-17 15:16:12,382 WARN org.docx4j.fonts.RunFontSelector - Font 'Arial' is not mapped to a physical font.
2021-03-17 15:16:12,382 INFO org.docx4j.fonts.RunFontSelector - No physical font for Arial
2021-03-17 15:16:12,383 WARN org.docx4j.fonts.RunFontSelector - Font 'Arial' is not mapped to a physical font.
2021-03-17 15:16:12,383 INFO org.docx4j.fonts.RunFontSelector - No physical font for Arial
2021-03-17 15:16:12,384 WARN org.docx4j.fonts.RunFontSelector - Font 'Times New Roman' is not mapped to a physical font.
2021-03-17 15:16:12,384 INFO org.docx4j.fonts.RunFontSelector - No physical font for Times New Roman
2021-03-17 15:16:12,385 WARN org.docx4j.fonts.RunFontSelector - Font 'Times New Roman' is not mapped to a physical font.
2021-03-17 15:16:12,385 INFO org.docx4j.fonts.RunFontSelector - No physical font for Times New Roman
2021-03-17 15:16:12,387 WARN org.docx4j.fonts.RunFontSelector - Font 'Arial' is not mapped to a physical font.
2021-03-17 15:16:12,387 INFO org.docx4j.fonts.RunFontSelector - No physical font for Arial
2021-03-17 15:16:12,388 WARN org.docx4j.fonts.RunFontSelector - Font 'Arial' is not mapped to a physical font.
2021-03-17 15:16:12,388 INFO org.docx4j.fonts.RunFontSelector - No physical font for Arial
2021-03-17 15:16:12,390 WARN org.docx4j.fonts.RunFontSelector - Font 'Arial' is not mapped to a physical font.
(From this point on, it takes a couple seconds logging these warnings)
I (think I) know it's seomthing I can change in my code, but I don't really know if it will help.
- Code: Select all
public void importarDocx(@ContextParam(ContextType.TRIGGER_EVENT) UploadEvent evento,
@BindingParam("wImp") Window wImp) throws Exception {
Media media = evento.getMedia();
String rutaOut = System.getProperty("java.io.tmpdir") + media.getName() +"_tmp.html";
/* Verifica si es un archivo válido. Rompe la operación si no lo es. */
if(!media.getName().endsWith(".docx")) {
mensajesBox.mensaje(WARNING, "Sólo puede importar archivos de extensión .docx", null);
setImportado(false);
media = null;
return;
}
WordprocessingMLPackage archivo = Docx4J.load(media.getStreamData());
/*HTML configuracion*/
HTMLSettings htmlSettings = Docx4J.createHTMLSettings();
htmlSettings.setOpcPackage(archivo);
String userCSS = "html, body, div, span, h1, h2, h3, h4, h5, h6, p, a, img, table, caption, tbody, tfoot, thead, tr, th, td, b, i, u" +
"{ margin: 0; padding: 0; border: 0;}" +
"body {line-height: 1.2;} ";
htmlSettings.setUserCSS(userCSS);
htmlSettings.setFontMapper(null); /**/
htmlSettings.getFeatures().remove(ConversionFeatures.PP_HTML_COLLECT_LISTS);
Mapper fontMapper = new IdentityPlusMapper(); /**/
PhysicalFonts.discoverPhysicalFonts(); /**/
fontMapper.put("Open Sans", PhysicalFonts.get("OpenSans-Regular")); /**/
archivo.setFontMapper(fontMapper); /**/
Docx4jProperties.setProperty("docx4j.Convert.Out.HTML.OutputMethodXML", true);
OutputStream os = new BufferedOutputStream (new FileOutputStream(rutaOut), 1024);
Docx4J.toHTML(htmlSettings, os, Docx4J.FLAG_EXPORT_PREFER_XSL);
/*extra work for our needs*/
os.close();
}
The lines annotaded with /**/ are the one I think should be changed. Probably using RFonts.setAscii is better, right?
Anyway, since I cannot reproduce this error on my machine and looking at the logs is painfull, I decided to ask for further help. I do believe this is a fonts related issue, but because this code have had worked before I'm not 100% certain that will fix it, and I really don't want to roll out my code with this not fixed. Is there anything else I should look into? I'm still getting the graps of thie whole Java EE environment so little things and configs might go over my head sometimes. Is this really just bad font management?
Thank you!