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(SVGShapeElementBridge.java:117)
at
org.apache.batik.bridge.SVGDecoratedShapeElementBridge.createFillStrokePainter(SVGDecoratedShapeElementBridge.java:58)
at
org.apache.batik.bridge.SVGDecoratedShapeElementBridge.createShapePainter(SVGDecoratedShapeElementBridge.java:84)
at
org.apache.batik.bridge.SVGShapeElementBridge.buildGraphicsNode(SVGShapeElementBridge.java:91)
at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:224)
at org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:171)
at org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:82)
at sc.fiji.io.SVG_Reader.run(SVG_Reader.java:53)

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/SVG_Reader.java:[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?

Regards,
Curtis

[1] E.g.:
https://github.com/fiji/IO/blob/IO_-3.0.3/src/main/java/sc/fiji/io/SVG_Reader.java

[2]
http://repo1.maven.org/maven2/org/apache/xmlgraphics/batik-bridge/1.9/batik-bridge-1.9.pom

[3]
https://github.com/apache/batik/blob/batik-1_9/batik-bridge/pom.xml#L88-L92

[4]
https://mail-archives.apache.org/mod_mbox/xmlgraphics-batik-users/201502.mbox/%3c54ceaf96.6040...@gmail.com%3E

[5]
https://github.com/fiji/IO/blob/e4da7347bee797daf5708b7045090eb90daf849b/pom.xml#L234-L244

--
Curtis Rueden
LOCI software architect - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
Did you know ImageJ has a forum? http://forum.imagej.net/

Reply via email to