我必须编译渲染插件使用的飞碟罐的自定义版本,以解决渲染和引导程序css的问题。它在本地工作正常......我可以将gsp渲染为PDF。如果我没有在lib目录中包含我的自定义jar,我会收到以下错误:
com.lowagie.text.pdf.BaseFont.getCharBBox(C)[I. Stacktrace follows:
org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: Executing action [invoiceAll] of controller [myapp.ReportsController] caused exception: Runtime error executing action
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:198)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.java:53)
at grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter.doFilter(RequestHolderAuthenticationFilter.java:49)
at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:82)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: Runtime error executing action
... 8 more
Caused by: java.lang.reflect.InvocationTargetException
... 8 more
Caused by: java.lang.NoSuchMethodError: com.lowagie.text.pdf.BaseFont.getCharBBox(C)[I
at org.xhtmlrenderer.pdf.ITextFontResolver$FontDescription.setMetricDefaults(ITextFontResolver.java:679)
at org.xhtmlrenderer.pdf.ITextFontResolver$FontDescription.<init>(ITextFontResolver.java:610)
at org.xhtmlrenderer.pdf.ITextFontResolver.addCourier(ITextFontResolver.java:410)
at org.xhtmlrenderer.pdf.ITextFontResolver.createInitialFontMap(ITextFontResolver.java:390)
at org.xhtmlrenderer.pdf.ITextFontResolver.<init>(ITextFontResolver.java:52)
at org.xhtmlrenderer.pdf.ITextRenderer.<init>(ITextRenderer.java:115)
at org.xhtmlrenderer.pdf.ITextRenderer.<init>(ITextRenderer.java:102)
at grails.plugin.rendering.pdf.PdfRenderingService.doRender(PdfRenderingService.groovy:34)
at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:43)
at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:37)
at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:35)
at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:65)
at RenderingGrailsPlugin$_closure3.doCall(RenderingGrailsPlugin.groovy:59)
at myapp.ReportsController.invoiceAll(ReportsController.groovy:46)
... 8 more
所以,在本地做这件事很好。 lsof显示grails java进程使用的jar:
java 26951 myuser mem REG 253,14 105122 531524 /home/myuser/sworkspace/groovy/tls_billing/lib/flying-saucer-pdf-9.0.1-myapp.jar
java 26951 myuser mem REG 253,14 1106329 528159 /home/myuser/sworkspace/groovy/tls_billing/lib/flying-saucer-core-9.0.1-myapp.jar
java 26951 myuser mem REG 253,14 105172 531525 /home/myuser/sworkspace/groovy/tls_billing/lib/flying-saucer-pdf-itext5-9.0.1-myapp.jar
java 26951 myuser 68r REG 253,14 105172 531525 /home/myuser/sworkspace/groovy/tls_billing/lib/flying-saucer-pdf-itext5-9.0.1-myapp.jar
java 26951 myuser 69r REG 253,14 1106329 528159 /home/myuser/sworkspace/groovy/tls_billing/lib/flying-saucer-core-9.0.1-myapp.jar
java 26951 myuser 75r REG 253,14 105122 531524 /home/myuser/sworkspace/groovy/tls_billing/lib/flying-saucer-pdf-9.0.1-myapp.jar
为了安全起见,我还在当地为罐子做了准备:
2c135a987892978d670cd73e789fa3337d50e7ff lib/flying-saucer-core-9.0.1-myapp.jar
b774052563a12fc212370a1c1a8a71ea5b8c0e87 lib/flying-saucer-pdf-9.0.1-myapp.jar
64c01c5f3425b0723b0d2e4a034fe9f23e3e1720 lib/flying-saucer-pdf-itext5-9.0.1-myapp.jar
因此,在“grails war”然后部署到远程Tomcat服务器之后,我收到以下错误:
2015-07-15 16:56:20,221 [http-bio-80-exec-1] ERROR StackTrace - Full Stack Trace:
java.lang.reflect.InvocationTargetException
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:198)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.java:53)
at grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter.doFilter(RequestHolderAuthenticationFilter.java:49)
at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:82)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoSuchMethodError: com.lowagie.text.pdf.BaseFont.getCharBBox(C)[I
at org.xhtmlrenderer.pdf.ITextFontResolver$FontDescription.setMetricDefaults(ITextFontResolver.java:679)
at org.xhtmlrenderer.pdf.ITextFontResolver$FontDescription.<init>(ITextFontResolver.java:610)
at org.xhtmlrenderer.pdf.ITextFontResolver.addCourier(ITextFontResolver.java:410)
at org.xhtmlrenderer.pdf.ITextFontResolver.createInitialFontMap(ITextFontResolver.java:390)
at org.xhtmlrenderer.pdf.ITextFontResolver.<init>(ITextFontResolver.java:52)
at org.xhtmlrenderer.pdf.ITextRenderer.<init>(ITextRenderer.java:115)
at org.xhtmlrenderer.pdf.ITextRenderer.<init>(ITextRenderer.java:102)
at grails.plugin.rendering.pdf.PdfRenderingService.doRender(PdfRenderingService.groovy:34)
at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:43)
at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:37)
at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:35)
at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:65)
at RenderingGrailsPlugin$_closure3.doCall(RenderingGrailsPlugin.groovy:59)
at myapp.ReportsController.invoiceAll(ReportsController.groovy:46)
... 8 more
2015-07-15 16:56:20,221 [http-bio-80-exec-1] ERROR StackTrace - Full Stack Trace:
java.lang.NoSuchMethodError: com.lowagie.text.pdf.BaseFont.getCharBBox(C)[I
at org.xhtmlrenderer.pdf.ITextFontResolver$FontDescription.setMetricDefaults(ITextFontResolver.java:679)
at org.xhtmlrenderer.pdf.ITextFontResolver$FontDescription.<init>(ITextFontResolver.java:610)
at org.xhtmlrenderer.pdf.ITextFontResolver.addCourier(ITextFontResolver.java:410)
at org.xhtmlrenderer.pdf.ITextFontResolver.createInitialFontMap(ITextFontResolver.java:390)
at org.xhtmlrenderer.pdf.ITextFontResolver.<init>(ITextFontResolver.java:52)
at org.xhtmlrenderer.pdf.ITextRenderer.<init>(ITextRenderer.java:115)
at org.xhtmlrenderer.pdf.ITextRenderer.<init>(ITextRenderer.java:102)
at grails.plugin.rendering.pdf.PdfRenderingService.doRender(PdfRenderingService.groovy:34)
at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:43)
at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:37)
at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:35)
at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:65)
at RenderingGrailsPlugin$_closure3.doCall(RenderingGrailsPlugin.groovy:59)
at myapp.ReportsController.invoiceAll(ReportsController.groovy:46)
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:198)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.java:53)
at grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter.doFilter(RequestHolderAuthenticationFilter.java:49)
at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:82)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
2015-07-15 16:56:20,221 [http-bio-80-exec-1] ERROR StackTrace - Full Stack Trace:
org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: Executing action [invoiceAll] of controller [myapp.ReportsController] caused exception: Runtime error executing action
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:198)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.java:53)
at grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter.doFilter(RequestHolderAuthenticationFilter.java:49)
at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:82)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: Runtime error executing action
... 8 more
Caused by: java.lang.reflect.InvocationTargetException
... 8 more
Caused by: java.lang.NoSuchMethodError: com.lowagie.text.pdf.BaseFont.getCharBBox(C)[I
at org.xhtmlrenderer.pdf.ITextFontResolver$FontDescription.setMetricDefaults(ITextFontResolver.java:679)
at org.xhtmlrenderer.pdf.ITextFontResolver$FontDescription.<init>(ITextFontResolver.java:610)
at org.xhtmlrenderer.pdf.ITextFontResolver.addCourier(ITextFontResolver.java:410)
at org.xhtmlrenderer.pdf.ITextFontResolver.createInitialFontMap(ITextFontResolver.java:390)
at org.xhtmlrenderer.pdf.ITextFontResolver.<init>(ITextFontResolver.java:52)
at org.xhtmlrenderer.pdf.ITextRenderer.<init>(ITextRenderer.java:115)
at org.xhtmlrenderer.pdf.ITextRenderer.<init>(ITextRenderer.java:102)
at grails.plugin.rendering.pdf.PdfRenderingService.doRender(PdfRenderingService.groovy:34)
at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:43)
at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:37)
at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:35)
at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:65)
at RenderingGrailsPlugin$_closure3.doCall(RenderingGrailsPlugin.groovy:59)
at myapp.ReportsController.invoiceAll(ReportsController.groovy:46)
... 8 more
为了确定,我进入/ opt / tomcat / webapps / ROOT / WEB-INF / lib(部署我的应用程序)并运行:
$ sha1sum flying-saucer-*
2c135a987892978d670cd73e789fa3337d50e7ff flying-saucer-core-9.0.1-myapp.jar
b774052563a12fc212370a1c1a8a71ea5b8c0e87 flying-saucer-pdf-9.0.1-myapp.jar
64c01c5f3425b0723b0d2e4a034fe9f23e3e1720 flying-saucer-pdf-itext5-9.0.1-myapp.jar
匹配。但是,应用程序实际上是否持有文件句柄对罐子开放?
首先,在我没有加载URL之后,它似乎不是:
$ sudo lsof | grep flying | wc -l
0
我认为Tomcat会旋转线程,因为在访问使用jar的URL(并导致异常)之后,我会点击:
$ sudo lsof | grep flying
F/lib/flying-saucer-pdf-itext5-9.0.1-myapp.jar
java 24487 24542 root mem REG 254,0 1106329 268857 /opt/apache-tomcat-7.0.61/webapps/ROOT/WEB-INF/lib/flying-saucer-core-9.0.1-myapp.jar
java 24487 24542 root mem REG 254,0 105122 268824 /opt/apache-tomcat-7.0.61/webapps/ROOT/WEB-INF/lib/flying-saucer-pdf-9.0.1-myapp.jar
java 24487 24542 root 93r REG 254,0 1106329 268857 /opt/apache-tomcat-7.0.61/webapps/ROOT/WEB-INF/lib/flying-saucer-core-9.0.1-myapp.jar
java 24487 24542 root 94r REG 254,0 105122 268824 /opt/apache-tomcat-7.0.61/webapps/ROOT/WEB-INF/lib/flying-saucer-pdf-9.0.1-myapp.jar
java 24487 24542 root 95r REG 254,0 105172 268734 /opt/apache-tomcat-7.0.61/webapps/ROOT/WEB-INF/lib/flying-saucer-pdf-itext5-9.0.1-myapp.jar
java 24487 24559 root mem REG 254,0 105172 268734 /opt/apache-tomcat-7.0.61/webapps/ROOT/WEB-INF/lib/flying-saucer-pdf-itext5-9.0.1-myapp.jar
java 24487 24559 root mem REG 254,0 1106329 268857 /opt/apache-tomcat-7.0.61/webapps/ROOT/WEB-INF/lib/flying-saucer-core-9.0.1-myapp.jar
java 24487 24559 root mem REG 254,0 105122 268824 /opt/apache-tomcat-7.0.61/webapps/ROOT/WEB-INF/lib/flying-saucer-pdf-9.0.1-myapp.jar
java 24487 24559 root 93r REG 254,0 1106329 268857 /opt/apache-tomcat-7.0.61/webapps/ROOT/WEB-INF/lib/flying-saucer-core-9.0.1-myapp.jar
java 24487 24559 root 94r REG 254,0 105122 268824 /opt/apache-tomcat-7.0.61/webapps/ROOT/WEB-INF/lib/flying-saucer-pdf-9.0.1-myapp.jar
java 24487 24559 root 95r REG 254,0 105172 268734 /opt/apache-tomcat-7.0.61/webapps/ROOT/WEB-INF/lib/flying-saucer-pdf-itext5-9.0.1-myapp.jar
java 24487 24629 root mem REG 254,0 105172 268734 /opt/apache-tomcat-7.0.61/webapps/ROOT/WEB-INF/lib/flying-saucer-pdf-itext5-9.0.1-myapp.jar
java 24487 24629 root mem REG 254,0 1106329 268857 /opt/apache-tomcat-7.0.61/webapps/ROOT/WEB-INF/lib/flying-saucer-core-9.0.1-myapp.jar
java 24487 24629 root mem REG 254,0 105122 268824 /opt/apache-tomcat-7.0.61/webapps/ROOT/WEB-INF/lib/flying-saucer-pdf-9.0.1-myapp.jar
java 24487 24629 root 93r REG 254,0 1106329 268857 /opt/apache-tomcat-7.0.61/webapps/ROOT/WEB-INF/lib/flying-saucer-core-9.0.1-myapp.jar
java 24487 24629 root 94r REG 254,0 105122 268824 /opt/apache-tomcat-7.0.61/webapps/ROOT/WEB-INF/lib/flying-saucer-pdf-9.0.1-myapp.jar
java 24487 24629 root 95r REG 254,0 105172 268734 /opt/apache-tomcat-7.0.61/webapps/ROOT/WEB-INF/lib/flying-saucer-pdf-itext5-9.0.1-myapp.jar
...snip...
$ lsof | grep flyingsaucer | wc -l
228
所以,罐子已加载,但应用程序仍无法找到包含缺失方法的自定义编译罐。
我在这里做错了什么?感谢您提供的任何帮助。
答案 0 :(得分:2)
这看起来像是一个类路径冲突。启动Tomcat容器时,请尝试将-verbose
添加到JVM设置:
export JAVA_OPTS="-verbose"
然后从输出中检查从哪个JAR加载com.lowagie.text.pdf.BaseFont
并验证它是否正确。这将帮助您调试情况。
答案 1 :(得分:1)
我遇到了完全相同的问题,但在* .9.0.7版本的飞碟中似乎没问题。
问题是 BaseFont.getCharBBox()的签名自 itext-2.1.2 后发生了变化:
// from
public int[] getCharBBox(char c)
// to
public int[] getCharBBox(int c)
[]&#39; S