蜡染给萨克斯冲突的蜡染

时间:2012-08-06 04:47:31

标签: grails sax batik

我正在尝试使用带有grails的蜡染来向服务器上的PNG渲染一些SVG内容。

当我将依赖项添加到BuildConfig然后告诉IntelliJ加载更改时,我在IntelliJ中收到以下错误:

/Library/Java/JavaVirtualMachines/1.6.0_33-b03-424.jdk/Contents/Home/bin/java -Dgrails.home=/Applications/Dev/grails-2.1.0 -Dbase.dir=/Users/greg/Documents/development/git/liftyourgame-grails/webapp -Dtools.jar=/Library/Java/JavaVirtualMachines/1.6.0_33-b03-424.jdk/Contents/Home/lib/tools.jar -Dgroovy.starter.conf=/Applications/Dev/grails-2.1.0/conf/groovy-starter.conf -Xmx512M -XX:MaxPermSize=192m -javaagent:/Applications/IntelliJ IDEA 11.app/plugins/Grails/lib/grails_rt.jar -Dprint.grails.settings=true -Dfile.encoding=UTF-8 -classpath /Applications/Dev/grails-2.1.0/lib/org.codehaus.groovy/groovy-all/jars/groovy-all-1.8.6.jar:/Applications/Dev/grails-2.1.0/dist/grails-bootstrap-2.1.0.jar org.codehaus.groovy.grails.cli.support.GrailsStarter --main org.codehaus.groovy.grails.cli.GrailsScriptRunner --conf /Applications/Dev/grails-2.1.0/conf/groovy-starter.conf help

| Loading Grails 2.1.0
| Configuring classpath
| Error Error executing script Help: loader constraint violation: when resolving overridden method "org.apache.tools.ant.helper.ProjectHelper2$RootHandler.setDocumentLocator(Lorg/xml/sax/Locator;)V" the class loader (instance of org/codehaus/groovy/grails/cli/support/GrailsRootLoader) of the current class, org/apache/tools/ant/helper/ProjectHelper2$RootHandler, and its superclass loader (instance of <bootloader>), have different Class objects for the type org/xml/sax/Locator used in the signature (Use --stacktrace to see the full trace)

IDEA hook: Grails not found!
| Error java.lang.NullPointerException
| Error     at org.jetbrains.groovy.grails.rt.Agent$2.run(Agent.java:88)
| Error     at java.lang.Thread.run(Thread.java:680)

Grails clean也有类似的结果。

BuildConfig.groovy包含其他内容:

grails.project.dependency.resolution = {
    // inherit Grails' default dependencies
    inherits("global") {
        excludes 'slf4j-log4j12', 'xml-apis', 'xalan', 'xml-apis-ext', 'commons-logging', 'commons-io'
    }
    log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
    checksums true // Whether to verify checksums on resolve

    repositories {
        inherits true // Whether to inherit repository definitions from plugins
        grailsPlugins()
        grailsHome()
        grailsCentral()
        mavenCentral()
    }
    dependencies {
        compile "org.jadira.usertype:usertype.jodatime:1.9"
        compile "org.imgscalr:imgscalr-lib:4.0"
        compile("org.apache.xmlgraphics:batik-svg-dom:1.7")
            {
                excludes 'batik-xml', 'batik-dom', 'commons-javaflow',
                        'avalon-framework-api', 'avalon-framwork-impl',
                        'batik-css', 'batik-gvt', 'batik-script',
                        'slf4j-log4j12', 'xml-apis', 'xml-apis-ext', 'log4j', 'xercesImpl', 'xalan',
                        'antlr', 'commons-beanutils', 'commons-collections', 'commons-logging', 'xmlParserAPIs',
                        'ant', 'mondrian', 'groovy-all', 'saaj-api', 'servlet-api', 'spring-core', 'bsh',
                        'spring-beans', 'jaxen', 'persistence-api', 'jdtcore', 'bcmail-jdk16', 'bcprov-jdk16',
                        'bctsp-jdk16', 'bcmail-jdk14', 'bcprov-jdk14', 'bctsp-jdk14', 'xmlbeans'
            }

}

batik-svg-dom的pom包括一些其他蜡染罐以及xml-apis和xml-apis-ext。我的研究表明,xml依赖项可能会导致grails问题,并且除了jdk 1.4之外不需要它们,因此它们已被排除。

我还尝试使用IntelliJs工具跟踪其他org.xml.sax.Locator实例,但找到的唯一实例位于:/Applications/Dev/grails-2.1.0/lib/org.apache.ant/蚂蚁发射/罐/蚂蚁发射-1.8.2.jar!/org/apache/tools/ant/launch/Locator.class

我也尝试过grails refresh-dependencies,我尝试删除.grails文件夹但是我总是得到相同的结果。

有什么想法吗?

1 个答案:

答案 0 :(得分:3)

问题似乎是Batik包含了一个xml-apis版本,它与现在包含在JDK中的版本冲突。 (http://grails.1312388.n4.nabble.com/Problems-integrating-batik-with-grails-project-td4632728.html)所以,这就像你已经完成的那样排除'xml-apis'。但是,由于很多Batik的罐子都对xml-apis具有传递依赖性,因此很难让Grails排除它。这是最终对我有用的:

compile("org.apache.xmlgraphics:fop:0.94",
            "org.apache.xmlgraphics:batik-transcoder:1.7",
            "org.apache.xmlgraphics:batik-codec:1.7",
            "org.apache.xmlgraphics:batik-awt-util:1.7",
            "org.apache.xmlgraphics:batik-bridge:1.7",
            "org.apache.xmlgraphics:batik-dom:1.7",
            "org.apache.xmlgraphics:batik-gvt:1.7",
            "org.apache.xmlgraphics:batik-svg-dom:1.7",
            "org.apache.xmlgraphics:batik-svggen:1.7",
            "org.apache.xmlgraphics:batik-util:1.7",
            "org.apache.xmlgraphics:batik-xml:1.7",
            "org.apache.xmlgraphics:batik-anim:1.7",
            "org.apache.xmlgraphics:batik-css:1.7",
            "org.apache.xmlgraphics:batik-ext:1.7",
            "org.apache.xmlgraphics:batik-js:1.7",
            "org.apache.xmlgraphics:batik-parser:1.7",
            "org.apache.xmlgraphics:batik-script:1.7",
            "org.apache.xmlgraphics:xmlgraphics-commons:1.2",
            "commons-logging:commons-logging:1.0.4",
            "org.apache.avalon.framework:avalon-framework-api:4.3.1",
            "org.apache.avalon.framework:avalon-framework-impl:4.3.1",
            "xalan:xalan:2.6.0",
            "xml-apis:xml-apis-ext:1.3.04"
    ){
        transitive = false
    }

这基本上是我想要包含的Batik罐子的白名单。由于transitive = false,因此忽略传递依赖。

然而,我仍然无法让Batik工作 - 似乎有一个次要问题,即org.apache.batik.dom.svg.SVGOMDocument缺失,即使包含该类的必需的jar部署在我的战争。

你找到了另一种有效的解决方案吗?