跟踪了许多使用 BATIK 的问题和答案,我无法修复我的错误,并且找不到任何可能有帮助的内容。还有这个question没有答案。
我的问题是当我在应用程序上下载 pdf 时,发生错误(我什至尝试包含 jar):
java.lang.ClassNotFoundException: org.apache.batik.dom.svg.SVGOMDocument
在我的 jasper 报告中,我包含了以下内容:
<image>
<reportElement x="453" y="117" width="246" height="115"/>
<imageExpression class="net.sf.jasperreports.engine.JRRenderable"><![CDATA[net.sf.jasperreports.renderers.BatikRenderer.getInstance(new java.io.File("C:\\Project\\myProject\\web-app\\images\\tomcat.svg"))]]>
</imageExpression>
</image>
基本上,我的 BuildConfig.groovy 是这样的:
inherits("global") {
excludes 'xml-apis', 'xml-apis-ext', 'xercesImpl'
}
和我的依赖项:
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
为什么我无法下载?无效的 svg?我得到了this来自 wiki 的 svg。
最佳答案
检查您部署的代码是否存在 batik-svg-dom-1.7.jar 或 batik-all-1.7.jar(使用它也会大大缩短您的编译配置)。如果缺少,请手动添加它,看看是否可以解决您的问题。如果缺少,但是您的部署配置中缺少某些内容。
关于grails - java.lang.ClassNotFoundException : org. apache.batik.dom.svg.SVGOMDocument,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30602684/