Pom-fji 21.3.1 breaking dependencies

Hi

trying to follow @ctrueden’s warning in
Calling ImageJ ops in a plugin; output types:

… I tried using fiji-pom 21.3.1. But this breaks a lot of dependencies:
ImageJFunctions
ImageConverter
ImagePlus
Opener
and some more

The fix suggestion would be to add
net.imagj: ij 1.50e to the class path. But this shouldn’t this be handled by maven?

Can you please clarify what you mean by “breaks”?

Please post an SSCCE demonstrating the problems you are having. Without further specifics, I do not know what to suggest.

Generally speaking: recent versions of net.imagej:imagej no longer declare net.imagej:imagej-legacy as an inherited dependency. So you might need to add a dependency on net.imagej:imagej-legacy to your own POM.

That was the bit that had me confused. I ws getting used to pom-fiji to take care of all the imageJ dependencies.
I Had to add this:

<dependency>
   <groupId>net.imagej</groupId>
   <artifactId>ij</artifactId>
</dependency>

So here’s a dummy with the latest fiji-pom (21.3.1).

@Plugin(type = Command.class, menuPath = "Sandbox")
public class Sanbox implements Command {

    @Override
    public void run() {
        System.out.println("jaja");
    }

    public static void main(final String... args) throws Exception {
        final ImageJ ij = net.imagej.Main.launch(args);
        ij.command().run(Sanbox.class, true);
    }

}

this is the pom that goes with

<parent>
   <groupId>sc.fiji</groupId>
   <artifactId>pom-fiji</artifactId>
   <version>21.3.1-SNAPSHOT</version>
   <relativePath />
</parent>

<repositories>
   <repository>
      <id>imagej.public</id>
      <url>http://maven.imagej.net/content/groups/public</url>
   </repository>
</repositories>
<properties>
   <scijava.jvm.version>1.8</scijava.jvm.version>
</properties>

<groupId>unifr-bioimage-ij2</groupId>
<artifactId>sandbox-2</artifactId>
<version>1.0.0-SNAPSHOT</version>

<dependencies>
   <dependency>
      <groupId>net.imagej</groupId>
      <artifactId>imagej</artifactId>
   </dependency>
</dependencies>

The error being

/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/bin/java -Didea.launcher.port=7541 "-Didea.launcher.bin.path=/Applications/IntelliJ IDEA.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/lib/packager.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/lib/tools.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/javaws.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/jfxswt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/ext/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Users/turf/.m2/repository/net/imagej/pom-imagej/14.8.0/target/classes:/Users/turf/.m2/repository/net/imagej/imagej/2.0.0-rc-46/imagej-2.0.0-rc-46.jar:/Users/turf/.m2/repository/net/imagej/imagej-common/0.20.1/imagej-common-0.20.1.jar:/Users/turf/.m2/repository/net/imglib2/imglib2/2.6.0/imglib2-2.6.0.jar:/Users/turf/.m2/repository/net/imglib2/imglib2-roi/0.4.2/imglib2-roi-0.4.2.jar:/Users/turf/.m2/repository/net/sf/trove4j/trove4j/3.0.3/trove4j-3.0.3.jar:/Users/turf/.m2/repository/edu/ucar/udunits/4.3.18/udunits-4.3.18.jar:/Users/turf/.m2/repository/net/imagej/imagej-ops/0.26.0/imagej-ops-0.26.0.jar:/Users/turf/.m2/repository/net/imglib2/imglib2-algorithm/0.3.3/imglib2-algorithm-0.3.3.jar:/Users/turf/.m2/repository/gov/nist/math/jama/1.0.3/jama-1.0.3.jar:/Users/turf/.m2/repository/net/imglib2/imglib2-algorithm-fft/0.1.2/imglib2-algorithm-fft-0.1.2.jar:/Users/turf/.m2/repository/edu/mines/mines-jtk/20151125/mines-jtk-20151125.jar:/Users/turf/.m2/repository/net/imglib2/imglib2-realtransform/2.0.0-beta-30/imglib2-realtransform-2.0.0-beta-30.jar:/Users/turf/.m2/repository/org/scijava/scijava-expression-parser/2.1.1/scijava-expression-parser-2.1.1.jar:/Users/turf/.m2/repository/org/scijava/scripting-javascript/0.4.3/scripting-javascript-0.4.3.jar:/Users/turf/.m2/repository/org/apache/commons/commons-math3/3.4.1/commons-math3-3.4.1.jar:/Users/turf/.m2/repository/net/imagej/imagej-updater/0.7.9/imagej-updater-0.7.9.jar:/Users/turf/.m2/repository/io/scif/scifio/0.27.1/scifio-0.27.1.jar:/Users/turf/.m2/repository/io/scif/scifio-jai-imageio/1.1.0/scifio-jai-imageio-1.1.0.jar:/Users/turf/.m2/repository/org/mapdb/mapdb/1.0.3/mapdb-1.0.3.jar:/Users/turf/.m2/repository/org/scijava/scijava-common/2.53.0/scijava-common-2.53.0.jar:/Users/turf/.m2/repository/com/googlecode/gentyref/gentyref/1.1.0/gentyref-1.1.0.jar:/Users/turf/.m2/repository/org/bushe/eventbus/1.4/eventbus-1.4.jar:/Users/turf/.m2/repository/net/imagej/imagej-deprecated/0.1.1/imagej-deprecated-0.1.1.jar:/Users/turf/.m2/repository/net/imagej/imagej-plugins-commands/0.6.0/imagej-plugins-commands-0.6.0.jar:/Users/turf/.m2/repository/com/github/sbridges/object-inspector/object-inspector/0.1/object-inspector-0.1.jar:/Users/turf/.m2/repository/net/iharder/base64/2.3.8/base64-2.3.8.jar:/Users/turf/.m2/repository/net/imagej/imagej-plugins-tools/0.3.0/imagej-plugins-tools-0.3.0.jar:/Users/turf/.m2/repository/net/imagej/imagej-plugins-uploader-ssh/0.3.0/imagej-plugins-uploader-ssh-0.3.0.jar:/Users/turf/.m2/repository/com/jcraft/jsch/0.1.49/jsch-0.1.49.jar:/Users/turf/.m2/repository/net/imagej/imagej-plugins-uploader-webdav/0.2.0/imagej-plugins-uploader-webdav-0.2.0.jar:/Users/turf/.m2/repository/net/imagej/imagej-scripting/0.2.4/imagej-scripting-0.2.4.jar:/Users/turf/.m2/repository/org/scijava/scripting-jython/0.3.0/scripting-jython-0.3.0.jar:/Users/turf/.m2/repository/org/scijava/jython-shaded/2.5.3/jython-shaded-2.5.3.jar:/Users/turf/.m2/repository/org/scijava/scripting-java/0.3.5/scripting-java-0.3.5.jar:/Users/turf/.m2/repository/org/scijava/minimaven/2.2.0/minimaven-2.2.0.jar:/Users/turf/.m2/repository/org/scijava/scripting-groovy/0.2.4/scripting-groovy-0.2.4.jar:/Users/turf/.m2/repository/org/codehaus/groovy/groovy/2.3.6/groovy-2.3.6.jar:/Users/turf/.m2/repository/org/scijava/scripting-clojure/0.1.4/scripting-clojure-0.1.4.jar:/Users/turf/.m2/repository/org/clojure/clojure/1.6.0/clojure-1.6.0.jar:/Users/turf/.m2/repository/org/scijava/scripting-beanshell/0.2.4/scripting-beanshell-0.2.4.jar:/Users/turf/.m2/repository/org/beanshell/bsh/2.0b4/bsh-2.0b4.jar:/Users/turf/.m2/repository/org/scijava/scripting-jruby/0.2.4/scripting-jruby-0.2.4.jar:/Users/turf/.m2/repository/org/jruby/jruby-core/1.7.12/jruby-core-1.7.12.jar:/Users/turf/.m2/repository/org/ow2/asm/asm/4.0/asm-4.0.jar:/Users/turf/.m2/repository/org/ow2/asm/asm-commons/4.0/asm-commons-4.0.jar:/Users/turf/.m2/repository/org/ow2/asm/asm-tree/4.0/asm-tree-4.0.jar:/Users/turf/.m2/repository/org/ow2/asm/asm-analysis/4.0/asm-analysis-4.0.jar:/Users/turf/.m2/repository/org/ow2/asm/asm-util/4.0/asm-util-4.0.jar:/Users/turf/.m2/repository/org/jruby/joni/joni/2.1.1/joni-2.1.1.jar:/Users/turf/.m2/repository/com/github/jnr/jnr-netdb/1.1.2/jnr-netdb-1.1.2.jar:/Users/turf/.m2/repository/com/github/jnr/jnr-enxio/0.4/jnr-enxio-0.4.jar:/Users/turf/.m2/repository/com/github/jnr/jnr-x86asm/1.0.2/jnr-x86asm-1.0.2.jar:/Users/turf/.m2/repository/com/github/jnr/jnr-unixsocket/0.3/jnr-unixsocket-0.3.jar:/Users/turf/.m2/repository/com/github/jnr/jnr-posix/3.0.1/jnr-posix-3.0.1.jar:/Users/turf/.m2/repository/org/jruby/extras/bytelist/1.0.11/bytelist-1.0.11.jar:/Users/turf/.m2/repository/com/github/jnr/jnr-constants/0.8.5/jnr-constants-0.8.5.jar:/Users/turf/.m2/repository/org/jruby/jcodings/jcodings/1.0.10/jcodings-1.0.10.jar:/Users/turf/.m2/repository/com/github/jnr/jnr-ffi/1.0.7/jnr-ffi-1.0.7.jar:/Users/turf/.m2/repository/com/github/jnr/jffi/1.2.7/jffi-1.2.7.jar:/Users/turf/.m2/repository/com/github/jnr/jffi/1.2.7/jffi-1.2.7-native.jar:/Users/turf/.m2/repository/org/yaml/snakeyaml/1.13/snakeyaml-1.13.jar:/Users/turf/.m2/repository/com/jcraft/jzlib/1.1.2/jzlib-1.1.2.jar:/Users/turf/.m2/repository/com/headius/invokebinder/1.2/invokebinder-1.2.jar:/Users/turf/.m2/repository/com/martiansoftware/nailgun-server/0.9.1/nailgun-server-0.9.1.jar:/Users/turf/.m2/repository/org/jruby/yecht/1.0/yecht-1.0.jar:/Users/turf/.m2/repository/joda-time/joda-time/2.3/joda-time-2.3.jar:/Users/turf/.m2/repository/com/headius/options/1.1/options-1.1.jar:/Users/turf/.m2/repository/org/jruby/jruby-stdlib/1.7.12/jruby-stdlib-1.7.12.jar:/Users/turf/.m2/repository/org/scijava/scripting-renjin/0.1.0/scripting-renjin-0.1.0.jar:/Users/turf/.m2/repository/org/renjin/renjin-script-engine/0.8.1891/renjin-script-engine-0.8.1891.jar:/Users/turf/.m2/repository/org/renjin/renjin-core/0.8.1891/renjin-core-0.8.1891.jar:/Users/turf/.m2/repository/org/apache/commons/commons-math/2.2/commons-math-2.2.jar:/Users/turf/.m2/repository/org/renjin/gcc-runtime/0.8.1891/gcc-runtime-0.8.1891.jar:/Users/turf/.m2/repository/org/netlib/netlib-java/0.9.3-renjin-patched-2/netlib-java-0.9.3-renjin-patched-2.jar:/Users/turf/.m2/repository/org/netlib/lapack/0.8/lapack-0.8.jar:/Users/turf/.m2/repository/org/netlib/f2jutil/0.8/f2jutil-0.8.jar:/Users/turf/.m2/repository/org/netlib/xerbla/0.8/xerbla-0.8.jar:/Users/turf/.m2/repository/org/netlib/blas/0.8/blas-0.8.jar:/Users/turf/.m2/repository/org/apache/commons/commons-vfs2/2.0/commons-vfs2-2.0.jar:/Users/turf/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:/Users/turf/.m2/repository/org/apache/maven/scm/maven-scm-api/1.4/maven-scm-api-1.4.jar:/Users/turf/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.jar:/Users/turf/.m2/repository/org/apache/maven/scm/maven-scm-provider-svnexe/1.4/maven-scm-provider-svnexe-1.4.jar:/Users/turf/.m2/repository/org/apache/maven/scm/maven-scm-provider-svn-commons/1.4/maven-scm-provider-svn-commons-1.4.jar:/Users/turf/.m2/repository/regexp/regexp/1.3/regexp-1.3.jar:/Users/turf/.m2/repository/org/apache/commons/commons-compress/1.4.1/commons-compress-1.4.1.jar:/Users/turf/.m2/repository/org/tukaani/xz/1.0/xz-1.0.jar:/Users/turf/.m2/repository/edu/emory/mathcs/jtransforms/2.4/jtransforms-2.4.jar:/Users/turf/.m2/repository/net/sf/jung/jung-api/2.0.1/jung-api-2.0.1.jar:/Users/turf/.m2/repository/net/sourceforge/collections/collections-generic/4.01/collections-generic-4.01.jar:/Users/turf/.m2/repository/net/sf/jung/jung-graph-impl/2.0.1/jung-graph-impl-2.0.1.jar:/Users/turf/.m2/repository/com/google/guava/guava/18.0/guava-18.0.jar:/Users/turf/.m2/repository/com/sun/codemodel/codemodel/2.6/codemodel-2.6.jar:/Users/turf/.m2/repository/org/renjin/stats/0.8.1891/stats-0.8.1891.jar:/Users/turf/.m2/repository/org/renjin/renjin-appl/0.8.1891/renjin-appl-0.8.1891.jar:/Users/turf/.m2/repository/org/renjin/renjin-gnur-runtime/0.8.1891/renjin-gnur-runtime-0.8.1891.jar:/Users/turf/.m2/repository/org/renjin/methods/0.8.1891/methods-0.8.1891.jar:/Users/turf/.m2/repository/org/renjin/datasets/0.8.1891/datasets-0.8.1891.jar:/Users/turf/.m2/repository/org/renjin/utils/0.8.1891/utils-0.8.1891.jar:/Users/turf/.m2/repository/org/renjin/grDevices/0.8.1891/grDevices-0.8.1891.jar:/Users/turf/.m2/repository/org/renjin/graphics/0.8.1891/graphics-0.8.1891.jar:/Users/turf/.m2/repository/org/scijava/scijava-plugins-commands/0.2.2/scijava-plugins-commands-0.2.2.jar:/Users/turf/.m2/repository/org/scijava/scijava-plugins-platforms/0.2.0/scijava-plugins-platforms-0.2.0.jar:/Users/turf/.m2/repository/org/scijava/scijava-plugins-text-markdown/0.1.2/scijava-plugins-text-markdown-0.1.2.jar:/Users/turf/.m2/repository/org/markdownj/markdownj/0.3.0-1.0.2b4/markdownj-0.3.0-1.0.2b4.jar:/Users/turf/.m2/repository/org/scijava/scijava-plugins-text-plain/0.1.2/scijava-plugins-text-plain-0.1.2.jar:/Users/turf/.m2/repository/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar" com.intellij.rt.execution.application.AppMain Sanbox
Exception in thread "main" java.lang.IllegalStateException: No UIs available.
    at org.scijava.ui.DefaultUIService.showUI(DefaultUIService.java:163)
    at org.scijava.AbstractGateway.launch(AbstractGateway.java:101)
    at net.imagej.Main.launch(Main.java:62)
    at Sanbox.main(Sanbox.java:36)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

This does not happen with the version 21.0.0 (a bit of title)

Your POM is incomplete. Surely you have a <dependencies> section as well? This is key for diagnosing such issues. Can you please post it?

you are right. I edited the post.

Thanks!

So, net.imagej:imagej is a toplevel project which brings in dependencies on all the lower level components. The exception is net.imagej:imagej-legacy, which is no longer brought in transitively. So if you also add:

<dependency>
  <groupId>net.imagej</groupId>
  <artifactId>imagej-legacy</artifactId>
</dependency>

in your deps section, you should see the error message go away, and the UI which appears should be the ImageJ 1.x UI as normal.

In short: you need to add a dependency on the user interface component of your choice. (net.imagej:imagej-ui-swing is another valid option.)

thanks for your patience @ctrueden
This was indeed what caused it.

why?

The imagej-legacy component does runtime patching of net.imagej:ij (i.e., ImageJ 1.x). There are class loading issues associated with this process—“landmines” which are easy for downstream consumers to step on, so to speak. And many people in fact did.

Furthermore, the ultimate purpose of ImageJ2 is to provide a clean redesign of ImageJ, such that the ImageJ 1.x library is no longer necessary whatsoever.

As such, we decided that by default, depending on ImageJ2 should not drag in ImageJ 1.x as a dependency. But you can still add it yourself if you wish.

See also imagej/imagej@e8fbfeee.

1 Like

thanks for the info.

Is possible yet to launch an imageJ instance (UI) without legacy?
The usual way to launch imageJ from the tutorials is:

final ImageJ ij = net.imagej.Main.launch(args);
ij.command().run(MyPlugin.class, true);

But that first line was also what triggered the error in the first place. Is there another way?

Sure. Just make sure imagej-legacy is not present on your runtime class-path.

Alternately, you can do:

final ImageJ ij = new ImageJ();
ij.ui().showUI("swing");

And it will display the ImageJ2 Swing user interface, instead of the legacy ImageJ 1.x UI.