java - Why am I suddenly getting an NPE on counters in Flying Saucer? -
i have html template have been using flying saucer pdf since last november. rebuilt project , same html , same code throwing npe. narrowed down page counters. when remove them works. here sample of html demonstrates issue.
<?xml version="1.0" encoding="utf-8" ?> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <style type="text/css"> @page { @top-right { content: element(header); } } #pagenumber:before { content: counter(page); } #pagecount:before { content: counter(pages); } </style> </head> <body> <header id="header" class="clearfix"> <div class="page-header"> <span class="label">order status</span><br/> page <div id="pagenumber"></div> of <div id="pagecount"></div> </div> </header> <div>hello world</div> </body> </html>
i sending payload small webservice uses flying saucer render , send back. code in service:
@requestmapping(value="/render", method= requestmethod.post) public void renderpdf(@requestbody string xhtmlcontent, httpservletresponse response) { itextrenderer renderer = new itextrenderer(); renderer.setdocumentfromstring(xhtmlcontent); renderer.layout(); //error happens here try { response.addheader("content-disposition", "attachment;filename=invoice.pdf"); response.setcontenttype("application/x-octet-stream"); renderer.createpdf(response.getoutputstream()); } catch (exception e) { logger.error("error creating pdf: ", e); } }
and following stack trace:
java.lang.nullpointerexception: null @ org.xhtmlrenderer.layout.breaker.breaker.getlanguage(breaker.java:136) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.layout.breaker.breaker.getbreakpointsprovider(breaker.java:124) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.layout.breaker.breaker.dobreaktext(breaker.java:147) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.layout.breaker.breaker.breaktext(breaker.java:112) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.layout.inlineboxing.layouttext(inlineboxing.java:848) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.layout.inlineboxing.layoutcontent(inlineboxing.java:201) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.render.blockbox.layoutinlinechildren(blockbox.java:983) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.render.blockbox.layoutchildren(blockbox.java:964) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.render.blockbox.layout(blockbox.java:847) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.render.blockbox.layout(blockbox.java:776) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.layout.blockboxing.layoutblockchild0(blockboxing.java:321) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.layout.blockboxing.layoutblockchild(blockboxing.java:299) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.layout.blockboxing.layoutcontent(blockboxing.java:90) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.render.blockbox.layoutchildren(blockbox.java:967) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.render.blockbox.layout(blockbox.java:847) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.render.blockbox.layout(blockbox.java:776) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.layout.blockboxing.layoutblockchild0(blockboxing.java:321) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.layout.blockboxing.layoutblockchild(blockboxing.java:299) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.layout.blockboxing.layoutcontent(blockboxing.java:90) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.render.blockbox.layoutchildren(blockbox.java:967) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.render.blockbox.layout(blockbox.java:847) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.render.blockbox.layout(blockbox.java:776) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.layout.blockboxing.layoutblockchild0(blockboxing.java:321) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.layout.blockboxing.layoutblockchild(blockboxing.java:299) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.layout.blockboxing.layoutcontent(blockboxing.java:90) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.render.blockbox.layoutchildren(blockbox.java:967) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.render.blockbox.layout(blockbox.java:847) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.render.blockbox.layout(blockbox.java:776) ~[flying-saucer-core-9.1.4.jar:na] @ org.xhtmlrenderer.pdf.itextrenderer.layout(itextrenderer.java:229) ~[flying-saucer-pdf-9.1.4.jar:na] @ com.byrne.pdfprinter.pdf.pdfcontroller.renderpdf(pdfcontroller.java:26) ~[classes/:na] @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) ~[na:1.8.0_112] @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) ~[na:1.8.0_112] @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) ~[na:1.8.0_112] @ java.lang.reflect.method.invoke(method.java:498) ~[na:1.8.0_112] @ org.springframework.web.method.support.invocablehandlermethod.doinvoke(invocablehandlermethod.java:221) ~[spring-web-4.3.2.release.jar:4.3.2.release] @ org.springframework.web.method.support.invocablehandlermethod.invokeforrequest(invocablehandlermethod.java:136) ~[spring-web-4.3.2.release.jar:4.3.2.release] @ org.springframework.web.servlet.mvc.method.annotation.servletinvocablehandlermethod.invokeandhandle(servletinvocablehandlermethod.java:114) ~[spring-webmvc-4.3.2.release.jar:4.3.2.release] @ org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.invokehandlermethod(requestmappinghandleradapter.java:827) ~[spring-webmvc-4.3.2.release.jar:4.3.2.release] @ org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.handleinternal(requestmappinghandleradapter.java:738) ~[spring-webmvc-4.3.2.release.jar:4.3.2.release] @ org.springframework.web.servlet.mvc.method.abstracthandlermethodadapter.handle(abstracthandlermethodadapter.java:85) ~[spring-webmvc-4.3.2.release.jar:4.3.2.release] @ org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:963) ~[spring-webmvc-4.3.2.release.jar:4.3.2.release] @ org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:897) ~[spring-webmvc-4.3.2.release.jar:4.3.2.release] @ org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:970) ~[spring-webmvc-4.3.2.release.jar:4.3.2.release] @ org.springframework.web.servlet.frameworkservlet.dopost(frameworkservlet.java:872) ~[spring-webmvc-4.3.2.release.jar:4.3.2.release] @ javax.servlet.http.httpservlet.service(httpservlet.java:648) ~[tomcat-embed-core-8.5.4.jar:8.5.4] @ org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:846) ~[spring-webmvc-4.3.2.release.jar:4.3.2.release] @ javax.servlet.http.httpservlet.service(httpservlet.java:729) ~[tomcat-embed-core-8.5.4.jar:8.5.4] @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:230) ~[tomcat-embed-core-8.5.4.jar:8.5.4] @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:165) ~[tomcat-embed-core-8.5.4.jar:8.5.4] @ org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52) ~[tomcat-embed-websocket-8.5.4.jar:8.5.4] @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:192) ~[tomcat-embed-core-8.5.4.jar:8.5.4] @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:165) ~[tomcat-embed-core-8.5.4.jar:8.5.4] @ org.springframework.web.filter.requestcontextfilter.dofilterinternal(requestcontextfilter.java:99) ~[spring-web-4.3.2.release.jar:4.3.2.release] @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:107) ~[spring-web-4.3.2.release.jar:4.3.2.release] @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:192) ~[tomcat-embed-core-8.5.4.jar:8.5.4] @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:165) ~[tomcat-embed-core-8.5.4.jar:8.5.4] @ org.springframework.web.filter.httpputformcontentfilter.dofilterinternal(httpputformcontentfilter.java:87) ~[spring-web-4.3.2.release.jar:4.3.2.release] @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:107) ~[spring-web-4.3.2.release.jar:4.3.2.release] @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:192) ~[tomcat-embed-core-8.5.4.jar:8.5.4] @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:165) ~[tomcat-embed-core-8.5.4.jar:8.5.4] @ org.springframework.web.filter.hiddenhttpmethodfilter.dofilterinternal(hiddenhttpmethodfilter.java:77) ~[spring-web-4.3.2.release.jar:4.3.2.release] @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:107) ~[spring-web-4.3.2.release.jar:4.3.2.release] @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:192) ~[tomcat-embed-core-8.5.4.jar:8.5.4] @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:165) ~[tomcat-embed-core-8.5.4.jar:8.5.4] @ org.springframework.web.filter.characterencodingfilter.dofilterinternal(characterencodingfilter.java:197) ~[spring-web-4.3.2.release.jar:4.3.2.release] @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:107) ~[spring-web-4.3.2.release.jar:4.3.2.release] @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:192) ~[tomcat-embed-core-8.5.4.jar:8.5.4] @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:165) ~[tomcat-embed-core-8.5.4.jar:8.5.4] @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:198) ~[tomcat-embed-core-8.5.4.jar:8.5.4] @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:108) [tomcat-embed-core-8.5.4.jar:8.5.4] @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:522) [tomcat-embed-core-8.5.4.jar:8.5.4] @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:140) [tomcat-embed-core-8.5.4.jar:8.5.4] @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:79) [tomcat-embed-core-8.5.4.jar:8.5.4] @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:87) [tomcat-embed-core-8.5.4.jar:8.5.4] @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:349) [tomcat-embed-core-8.5.4.jar:8.5.4] @ org.apache.coyote.http11.http11processor.service(http11processor.java:1110) [tomcat-embed-core-8.5.4.jar:8.5.4] @ org.apache.coyote.abstractprocessorlight.process(abstractprocessorlight.java:66) [tomcat-embed-core-8.5.4.jar:8.5.4] @ org.apache.coyote.abstractprotocol$connectionhandler.process(abstractprotocol.java:785) [tomcat-embed-core-8.5.4.jar:8.5.4] @ org.apache.tomcat.util.net.nioendpoint$socketprocessor.dorun(nioendpoint.java:1425) [tomcat-embed-core-8.5.4.jar:8.5.4] @ org.apache.tomcat.util.net.socketprocessorbase.run(socketprocessorbase.java:49) [tomcat-embed-core-8.5.4.jar:8.5.4] @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1142) [na:1.8.0_112] @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:617) [na:1.8.0_112] @ org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61) [tomcat-embed-core-8.5.4.jar:8.5.4] @ java.lang.thread.run(thread.java:745) [na:1.8.0_112]
again, let me reiterate, code worked before tried rebuild it. did not change flying saucer version, using release version in maven. ensure there weren't issues specified concrete version numbers going date when worked , little before , still happens.
as post i'm tracing through source haven't found yet.
the version 9.1.5 of flying saucer project fixed problem. 9.1.4 blame.
Comments
Post a Comment