Grails 蜡染与圣杯给萨克斯冲突

Grails 蜡染与圣杯给萨克斯冲突,grails,sax,batik,Grails,Sax,Batik,我正在尝试使用batik和grails在服务器上将一些SVG内容渲染为PNG 当我将依赖项添加到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

我正在尝试使用batik和grails在服务器上将一些SVG内容渲染为PNG

当我将依赖项添加到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)
batik svg dom的pom包括一些其他batik JAR以及xml API和xml-API-ext。我的研究表明,在grails下,xml依赖关系可能会造成麻烦,因为它们在jdk 1.4之外不需要,所以被排除在外

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

我还尝试过grails刷新依赖项,并尝试过删除.grails文件夹,但总是得到相同的结果


有什么想法吗

问题似乎在于Batik包含的xml API版本与现在包含在JDK中的版本冲突。()所以,这是一个排除“XMLAPI”的问题,正如您已经做的那样。然而,由于Batik的许多JAR对XMLAPI具有可传递的依赖性,因此很难让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
    }
这基本上是我想包括的蜡染罐的白名单。由于transitive=false,将忽略可传递依赖项

然而,我仍然无法让Batik真正发挥作用——似乎还有一个次要问题,即org.apache.Batik.dom.svg.SVGOMDocument缺失,即使在我的war中部署了包含该类的必需JAR


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

这也让我感到困惑。上面的答案是有效的,但当应用程序使用“grails run app”运行时,会出现“未找到类”异常。使用“grails run war”可以很好地工作。有关原因的更多信息,请参阅。
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
    }