java.lang.NoSuchMethodError:com.lowagie.text.pdf.BaseFont.getCharBBox(C)[I

时间:2015-10-12 16:13:05

标签: grails grails-plugin

我正在使用grails 2.3.7。我在这个地方受到了打击。试图找到解决方案但我不知道哪个可以解决我的问题。

   2015-10-12 14:15:08,908 ERROR [http-nio-8080-exec-5]     
   GrailsExceptionResolver.error(213) | NoSuchMethodError occurred when 
   processing request: [GET] /dispatch/renderAsPdf/3621410

   com.lowagie.text.pdf.BaseFont.getCharBBox(C)[I. Stacktrace follows:
   org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: Executing action [renderAsPdf] of controller
   [com.mymodelorder.model.DispatchController]  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.multitenant.core.servlet.CurrentTenantServletFilter.doFilter(CurrentTenantServletFilter.java:53)
   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:1142)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
   at java.lang.Thread.run(Thread.java:745)
   Caused by: org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: Runtime error executing action
    ... 9 more
   Caused by: java.lang.reflect.InvocationTargetException
    ... 9 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)

以下是 BuildConfig.groovy

  repositories {
    inherits false // Whether to inherit repository definitions from plugins
    grailsPlugins()
    grailsHome()
    grailsCentral()
    mavenLocal()
    mavenCentral()
    mavenRepo "http://snapshots.repository.codehaus.org"
    mavenRepo "http://repository.codehaus.org"
    mavenRepo "http://download.java.net/maven/2/"
    mavenRepo "http://repository.jboss.com/maven2/"
    mavenRepo "http://mvnrepository.com/"
    mavenRepo "http://repo.grails.org/grails/core"
    mavenRepo "https://raw.github.com/fernandezpablo85/scribe-java/mvn-repo"
    mavenRepo "http://repo.spring.io/milestone/"
 }

dependencies {
    runtime 'mysql:mysql-connector-java:5.1.27'
    compile 'com.paypal.sdk:adaptivepaymentssdk:2.5.106'
    compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.7'
    compile 'commons-beanutils:commons-beanutils:1.8.3'
 }


plugins {
    build ":tomcat:7.0.52.1"
    compile ":scaffolding:2.0.2"
    compile ':cache:1.1.1'
    runtime ":hibernate:3.6.10.9" // or ":hibernate4:4.3.4"
    runtime ":database-migration:1.4.0"
    runtime ":jquery:1.11.1"
    runtime ":resources:1.2.8"

    compile ":spring-security-core:2.0-RC4"
    compile ":multi-tenant-single-db:0.8.3"
    compile ":famfamfam:1.0.1"
    compile ":spring-security-ui:1.0-RC2"
    compile ":joda-time:1.5"

    runtime ":zipped-resources:1.0.1"
    runtime ":cached-resources:1.1"
    compile ":cache-headers:1.1.5"
    compile ":simple-captcha:1.0.0"
    compile ":cache:1.1.7"
    compile ":webxml:1.4.1"
    compile ":easygrid:1.4.5"
    compile ":jquery-ui:1.10.3"
    compile ":calendar:1.2.1"
    compile ":file-uploader:1.2.1"
    compile ":csv:0.3.1"
    compile ":paypal:0.6.8"
    compile ":rendering:1.0.0"
    /*runtime( "org.grails.plugins:rendering:1.0.0") {
      excludes "itext"
    }*/
    compile ":aws:1.7.5.0"
    compile ":remote-pagination:0.4.8"
    compile ":drop-box:1.3.1"

    compile ':spring-security-oauth:2.1.0-SNAPSHOT'
    compile ":spring-security-oauth-google:0.3.1"
    compile ':spring-security-oauth-facebook:0.1'
    compile ':spring-security-oauth-linkedin:0.1'
    compile ':spring-security-oauth-twitter:0.1'
 }

当我使用依赖项报告命令时,我发现以下与itext版本相关的详细信息。

+--- org.grails:grails-docs:2.3.7
|    \--- org.xhtmlrenderer:core-renderer:R8
|    \--- org.yaml:snakeyaml:1.8
|    \--- org.grails:grails-gdoc-engine:1.0.1
|    \--- com.lowagie:itext:2.0.8
|         \--- bouncycastle:bcmail-jdk14:138
|         \--- bouncycastle:bcprov-jdk14:138
|    \--- commons-lang:commons-lang:2.6

+--- org.grails.plugins:rendering:1.0.0
|    \--- org.xhtmlrenderer:core-renderer:R8
|    \--- com.lowagie:itext:2.1.0
|         \--- bouncycastle:bcmail-jdk14:136
|         \--- bouncycastle:bcprov-jdk14:136

我不知道为什么这个错误早些时候它正常工作但是 现在给出错误像上面提到的itext版本。

请帮帮我。

3 个答案:

答案 0 :(得分:2)

您可以通过从其中一个插件中排除itext依赖项来解决问题。就我而言,冲突的插件是exportrendering

我决定将其从export插件中排除,如下所示:

compile (':export:1.6') { excludes 'itext', 'itext-rtf' }

答案 1 :(得分:0)

Grails 3.这些运行时覆盖似乎解决了我的问题:

ShowA

这是我找到解决方案的帖子: https://github.com/gpc/rendering/issues/4

答案 2 :(得分:0)

用以下替换旧的依赖项,它起作用了:

    <dependency>
        <groupId>com.lowagie</groupId>
        <artifactId>itext</artifactId>
        <version>4.2.1</version>
    </dependency>

    <dependency>
        <groupId>org.xhtmlrenderer</groupId>
        <artifactId>flying-saucer-pdf</artifactId>
        <version>9.0.9</version>
    </dependency>

    <dependency>
        <groupId>com.lowagie</groupId>
        <artifactId>itext</artifactId>
    </dependency>

此链接中描述了解决方案:https://github.com/longyu065/flying-saucer/issues/126