batik-bridge does not declare xmlgraphics-commons dependency

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

batik-bridge does not declare xmlgraphics-commons dependency

Curtis Rueden
Hi everyone,

I maintain some projects which use Batik for reading SVG files [1]. All works very well; thank you very much for this great library!

These projects depend on batik components via Maven. I noticed that batik-bridge requires xmlgraphics-commons, but does not declare it in its POM. So without xmlgraphics-commons on the classpath, there are runtime errors like:

java.lang.NoClassDefFoundError: org/apache/xmlgraphics/java2d/color/DeviceCMYKColorSpace
at org.apache.batik.bridge.SVGShapeElementBridge.createShapePainter(
at org.apache.batik.bridge.SVGDecoratedShapeElementBridge.createFillStrokePainter(
at org.apache.batik.bridge.SVGDecoratedShapeElementBridge.createShapePainter(
at org.apache.batik.bridge.SVGShapeElementBridge.buildGraphicsNode(
at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(
at org.apache.batik.bridge.GVTBuilder.buildComposite(

If you look at the POM on Maven Central [2], you'll see that xmlgraphics-commons is not one of the dependencies. But if you look at the POM of the release tag [3], you'll see that it is. Apparently there was a similar issue back in 2015, but it was fixed [4].

Similarly, batik-constants seems to be required even at compile time; without it, javac says:

  [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.0:compile (default-compile) on project IO_: Compilation failure
  [ERROR] /Users/curtis/code/fiji/IO/src/main/java/sc/fiji/io/[53,33] cannot access org.apache.batik.util.XMLConstants
  [ERROR]   class file for org.apache.batik.util.XMLConstants not found

Where the line of code in question has no direct reference to XMLConstants.

(As an aside: in contrast to javac, the Eclipse compiler does not complain about this when batik-constants is missing from the compile-time classpath.)

To work around this problem, we declare batik-constants and xmlgraphics-commons explicitly as dependencies [5].

I am curious if this dependency weirdness is a known issue, and if a fix is planned?


Curtis Rueden
LOCI software architect -
ImageJ2 lead, Fiji maintainer -
Did you know ImageJ has a forum?