'Batik not in classpath' error when running servlet

折月煮酒 提交于 2019-12-01 19:30:34

It appears to be a bug in Fop where they forgot to include a dependency.

The missing class is in the JAR file - xml-apis-ext.jar Which is also available from the Apache xml-commons project.

The error message is misleading, this is really a lack of xml commons external.

If you are executing Batik from fedora using the .jar file it is quite painful due to the java ignoring the -classpath flag. I assume batik in /usr/share/java Select the location according to your system One solution could be the following: create a scratch directory (I assume you are superuser, anyway you always can sudo commands)

# mkdir scratch
# cd scratch
# jar -xf /usr/share/java/batik-rasterizer.jar

This output the content of the jar file into scratch, then create a MANIFEST.MF file or take the output one from the dump

#cp META-INF/MANIFEST.MF .

Now edit the MANIFEST.MF file (I like to use vi, anyone use their preferred one)

#vi MANIFEST.MF

Add a Class-Path: line into the MANIFEST.MF as for example:

Class-Path: batik-all.jar xmlgraphics-commons.jar xml-commons-apis-ext.jar pdf-transcoder.jar avalon-framework.jar avalon-framework-api.jar apache-commons-logging.jar apache-commons-io.jar

Then close the file and recreate the jar file

#jar cmf MANIFEST.MF /usr/share/java/batik-rasterizer.jar org/*

Include all jar that batik has nested classes

Then you can use it!

$java -jar /usr/share/java/batik-rasterizer.jar -scriptSecurittyOff -m image/png -d image.png image.svg

for example

And that is!!!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!