How to resolve duplicate classes in unshaded ome:jxrlib-all artifact?

I am working on improving the pom-scijava bill of materials to eliminate duplicate class conflicts between managed artifacts. I discovered that formats-bsd depends on an artifact ome:jxrlib-all, but I cannot find the code for this artifact anywhere. It’s a problem because it ships javax.xml.bind and com.sun.xml.bind classes, which conflicts with jakarta.xml.bind:jakarta.xml.bind-api and javax.xml.bind:jaxb-api (in the case of javax.xml.bind) as well as org.glassfish.jaxb:jaxb-runtime (in the case of com.sun.xml.bind). It has other unshaded classes too: the com.sun.istack package which clashes with com.sun.istack:istack-commons-runtime, and com.sun.xml.txw2 which clashes with org.glassfish.jaxb:txw2.

What would you recommend to resolve this? I am guessing there should only be one implementation on the classpath for each of javax.xml.bind and com.sun.xml.bind, no? In which case, it is similar to the situation with SLF4J, where libraries should not transitively impose a preference, right?

For now, I added com.sun.istack and com.sun.xml.bind and com.sun.xml.txw2 and javax.xml.bind to the list of allowed-to-be-duplicated class prefixes to ignore the problem, but I just wanted to give a heads up because this may cause unexpected behavior in downstream consumers when multiple sources of these classes are on the classpath.

2 Likes

The jxrlib code is here:

The build that deployed (yes, even with the build failure) the 0.2.2 release of the -all artifact was this one:

The build failure, late in the testing phase, is an artifact of what has happened to the wider OME repositories since the last releases ~3 years ago. It is something we need to fix.

The -all artifact is basically just supposed to bring together the native artifacts that are built by Travis (macOS and Linuxs) and AppVeyor (Windows) into a single dependency. Let me see if I can find out why the javax.* and com.sun.* classes are in the package, they shouldn’t be.

4 Likes

Work on this just went in to the 0.2.x branch:

Have a look at the latest 0.2.3-SNAPSHOT release of jxrlib-all and see if it’s a little more what you’re expecting, @ctrueden.

1 Like

Looks great now, @chris-allan! Thanks a lot!

$ mvn dependency:get -Dartifact=ome:jxrlib-all:0.2.3-SNAPSHOT
...
$ jar tf ~/.m2/repository/ome/jxrlib-all/0.2.3-SNAPSHOT/jxrlib-all-0.2.3-SNAPSHOT.jar
META-INF/
META-INF/MANIFEST.MF
META-INF/maven/
META-INF/maven/ome/
META-INF/maven/ome/jxrlib-all/
META-INF/maven/ome/jxrlib-all/pom.xml
META-INF/maven/ome/jxrlib-all/pom.properties
ome/
ome/jxrlib/
ome/jxrlib/DecodeException.class
ome/jxrlib/ImageDecoder.class
ome/jxrlib/Resolution.class
ome/jxrlib/ImageData.class
ome/jxrlib/Factory.class
ome/jxrlib/Stream.class
ome/jxrlib/JXR.class
ome/jxrlib/CodecFactory.class
ome/jxrlib/Decode.class
ome/jxrlib/FormatConverter.class
ome/jxrlib/DecodeContext.class
ome/jxrlib/AbstractDecode.class
ome/jxrlib/FormatError.class
ome/jxrlib/JXRJNI.class
ome/jxrlib/ImageEncoder.class
ome/jxrlib/GUID.class
META-INF/maven/ome/jxrlib/
META-INF/maven/ome/jxrlib/pom.xml
META-INF/maven/ome/jxrlib/pom.properties
META-INF/lib/
META-INF/lib/windows_64/
META-INF/lib/windows_64/jxrjava.dll
META-INF/maven/ome/jxrlib-native-windows_64/
META-INF/maven/ome/jxrlib-native-windows_64/pom.xml
META-INF/maven/ome/jxrlib-native-windows_64/pom.properties
META-INF/lib/linux_64/
META-INF/lib/linux_64/libjxrjava.so
META-INF/maven/ome/jxrlib-native-linux_64/
META-INF/maven/ome/jxrlib-native-linux_64/pom.xml
META-INF/maven/ome/jxrlib-native-linux_64/pom.properties
META-INF/lib/osx_64/
META-INF/lib/osx_64/libjxrjava.dylib
META-INF/maven/ome/jxrlib-native-osx_64/
META-INF/maven/ome/jxrlib-native-osx_64/pom.xml
META-INF/maven/ome/jxrlib-native-osx_64/pom.properties
$ grep -A9999 '<dependencies>' ~/.m2/repository/ome/jxrlib-all/0.2.3-SNAPSHOT/jxrlib-all-0.2.3-SNAPSHOT.pom | grep -B9999 '<\/dependencies>'
  <dependencies>
    <dependency>
      <groupId>org.scijava</groupId>
      <artifactId>native-lib-loader</artifactId>
      <version>2.1.4</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>

Our pleasure. 0.2.3 has now been released and a version update PR opened against Bio-Formats:

2 Likes

Thanks @chris-allan. Unfortunately, when updating pom-scijava to manage jxrlib-all at version 0.2.3, I discovered that the released artifact now has other unshaded content—specifically, the args4j:args4j library:

$ jar tf ~/.m2/repository/ome/jxrlib-all/0.2.3/jxrlib-all-0.2.3.jar
META-INF/
META-INF/MANIFEST.MF
META-INF/maven/
META-INF/maven/ome/
META-INF/maven/ome/jxrlib-all/
META-INF/maven/ome/jxrlib-all/pom.xml
META-INF/maven/ome/jxrlib-all/pom.properties
ome/
ome/jxrlib/
ome/jxrlib/DecodeException.class
ome/jxrlib/ImageDecoder.class
ome/jxrlib/Resolution.class
ome/jxrlib/ImageData.class
ome/jxrlib/Factory.class
ome/jxrlib/Stream.class
ome/jxrlib/JXR.class
ome/jxrlib/CodecFactory.class
ome/jxrlib/Decode.class
ome/jxrlib/FormatConverter.class
ome/jxrlib/DecodeContext.class
ome/jxrlib/AbstractDecode.class
ome/jxrlib/FormatError.class
ome/jxrlib/JXRJNI.class
ome/jxrlib/ImageEncoder.class
ome/jxrlib/GUID.class
META-INF/maven/ome/jxrlib/
META-INF/maven/ome/jxrlib/pom.xml
META-INF/maven/ome/jxrlib/pom.properties
META-INF/lib/
META-INF/lib/windows_64/
META-INF/lib/windows_64/jxrjava.dll
META-INF/maven/ome/jxrlib-native-windows_64/
META-INF/maven/ome/jxrlib-native-windows_64/pom.xml
META-INF/maven/ome/jxrlib-native-windows_64/pom.properties
META-INF/lib/linux_64/
META-INF/lib/linux_64/libjxrjava.so
META-INF/maven/ome/jxrlib-native-linux_64/
META-INF/maven/ome/jxrlib-native-linux_64/pom.xml
META-INF/maven/ome/jxrlib-native-linux_64/pom.properties
META-INF/lib/osx_64/
META-INF/lib/osx_64/libjxrjava.dylib
META-INF/maven/ome/jxrlib-native-osx_64/
META-INF/maven/ome/jxrlib-native-osx_64/pom.xml
META-INF/maven/ome/jxrlib-native-osx_64/pom.properties
LICENSE
META-INF/maven/args4j/
META-INF/maven/args4j/args4j/
META-INF/maven/args4j/args4j/pom.properties
META-INF/maven/args4j/args4j/pom.xml
OSGI-OPT/
OSGI-OPT/src/
OSGI-OPT/src/org/
OSGI-OPT/src/org/kohsuke/
OSGI-OPT/src/org/kohsuke/args4j/
OSGI-OPT/src/org/kohsuke/args4j/Argument.java
OSGI-OPT/src/org/kohsuke/args4j/ClassParser.java
OSGI-OPT/src/org/kohsuke/args4j/CmdLineException.java
OSGI-OPT/src/org/kohsuke/args4j/CmdLineParser.java
OSGI-OPT/src/org/kohsuke/args4j/Config.java
OSGI-OPT/src/org/kohsuke/args4j/ExampleMode.java
OSGI-OPT/src/org/kohsuke/args4j/FieldParser.java
OSGI-OPT/src/org/kohsuke/args4j/IllegalAnnotationError.java
OSGI-OPT/src/org/kohsuke/args4j/Localizable.java
OSGI-OPT/src/org/kohsuke/args4j/Messages.java
OSGI-OPT/src/org/kohsuke/args4j/NamedOptionDef.java
OSGI-OPT/src/org/kohsuke/args4j/Option.java
OSGI-OPT/src/org/kohsuke/args4j/OptionDef.java
OSGI-OPT/src/org/kohsuke/args4j/OptionHandlerFilter.java
OSGI-OPT/src/org/kohsuke/args4j/OptionHandlerRegistry.java
OSGI-OPT/src/org/kohsuke/args4j/ParserProperties.java
OSGI-OPT/src/org/kohsuke/args4j/Starter.java
OSGI-OPT/src/org/kohsuke/args4j/Utilities.java
OSGI-OPT/src/org/kohsuke/args4j/XmlParser.java
OSGI-OPT/src/org/kohsuke/args4j/package.html
OSGI-OPT/src/org/kohsuke/args4j/spi/
OSGI-OPT/src/org/kohsuke/args4j/spi/AnnotationImpl.java
OSGI-OPT/src/org/kohsuke/args4j/spi/ArgumentImpl.java
OSGI-OPT/src/org/kohsuke/args4j/spi/ArrayFieldSetter.java
OSGI-OPT/src/org/kohsuke/args4j/spi/BooleanOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/ByteOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/CharOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/ConfigElement.java
OSGI-OPT/src/org/kohsuke/args4j/spi/DelimitedOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/DoubleOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/EnumOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/ExplicitBooleanOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/FieldSetter.java
OSGI-OPT/src/org/kohsuke/args4j/spi/FileOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/FloatOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/Getter.java
OSGI-OPT/src/org/kohsuke/args4j/spi/InetAddressOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/IntOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/LongOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/MacAddressOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/MapOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/Messages.java
OSGI-OPT/src/org/kohsuke/args4j/spi/MethodSetter.java
OSGI-OPT/src/org/kohsuke/args4j/spi/MultiFileOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/MultiPathOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/MultiValueFieldSetter.java
OSGI-OPT/src/org/kohsuke/args4j/spi/OneArgumentOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/OptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/OptionImpl.java
OSGI-OPT/src/org/kohsuke/args4j/spi/Parameters.java
OSGI-OPT/src/org/kohsuke/args4j/spi/PathOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/PatternOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/RestOfArgumentsHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/Setter.java
OSGI-OPT/src/org/kohsuke/args4j/spi/Setters.java
OSGI-OPT/src/org/kohsuke/args4j/spi/ShortOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/StopOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/StringArrayOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/StringOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/SubCommand.java
OSGI-OPT/src/org/kohsuke/args4j/spi/SubCommandHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/SubCommands.java
OSGI-OPT/src/org/kohsuke/args4j/spi/URIOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/URLOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/UuidOptionHandler.java
OSGI-OPT/src/org/kohsuke/args4j/spi/package.html
org/
org/kohsuke/
org/kohsuke/args4j/
org/kohsuke/args4j/Argument.class
org/kohsuke/args4j/ClassParser.class
org/kohsuke/args4j/CmdLineException.class
org/kohsuke/args4j/CmdLineParser$CmdLineImpl.class
org/kohsuke/args4j/CmdLineParser.class
org/kohsuke/args4j/Config$ConfigHandler.class
org/kohsuke/args4j/Config.class
org/kohsuke/args4j/ExampleMode$1.class
org/kohsuke/args4j/ExampleMode$2.class
org/kohsuke/args4j/ExampleMode.class
org/kohsuke/args4j/FieldParser.class
org/kohsuke/args4j/IllegalAnnotationError.class
org/kohsuke/args4j/Localizable.class
org/kohsuke/args4j/Messages.class
org/kohsuke/args4j/Messages.properties
org/kohsuke/args4j/Messages_de.properties
org/kohsuke/args4j/Messages_en.properties
org/kohsuke/args4j/Messages_ru.properties
org/kohsuke/args4j/NamedOptionDef.class
org/kohsuke/args4j/Option.class
org/kohsuke/args4j/OptionDef.class
org/kohsuke/args4j/OptionHandlerFilter$1.class
org/kohsuke/args4j/OptionHandlerFilter$2.class
org/kohsuke/args4j/OptionHandlerFilter$3.class
org/kohsuke/args4j/OptionHandlerFilter.class
org/kohsuke/args4j/OptionHandlerRegistry$DefaultConstructorHandlerFactory.class
org/kohsuke/args4j/OptionHandlerRegistry$OptionHandlerFactory.class
org/kohsuke/args4j/OptionHandlerRegistry.class
org/kohsuke/args4j/ParserProperties$1.class
org/kohsuke/args4j/ParserProperties.class
org/kohsuke/args4j/Starter.class
org/kohsuke/args4j/Utilities.class
org/kohsuke/args4j/XmlParser.class
org/kohsuke/args4j/spi/
org/kohsuke/args4j/spi/AnnotationImpl.class
org/kohsuke/args4j/spi/ArgumentImpl.class
org/kohsuke/args4j/spi/ArrayFieldSetter.class
org/kohsuke/args4j/spi/BooleanOptionHandler.class
org/kohsuke/args4j/spi/ByteOptionHandler.class
org/kohsuke/args4j/spi/CharOptionHandler.class
org/kohsuke/args4j/spi/ConfigElement.class
org/kohsuke/args4j/spi/DelimitedOptionHandler.class
org/kohsuke/args4j/spi/DoubleOptionHandler.class
org/kohsuke/args4j/spi/EnumOptionHandler.class
org/kohsuke/args4j/spi/ExplicitBooleanOptionHandler.class
org/kohsuke/args4j/spi/FieldSetter.class
org/kohsuke/args4j/spi/FileOptionHandler.class
org/kohsuke/args4j/spi/FloatOptionHandler.class
org/kohsuke/args4j/spi/Getter.class
org/kohsuke/args4j/spi/InetAddressOptionHandler.class
org/kohsuke/args4j/spi/IntOptionHandler.class
org/kohsuke/args4j/spi/LongOptionHandler.class
org/kohsuke/args4j/spi/MacAddressOptionHandler.class
org/kohsuke/args4j/spi/MapOptionHandler.class
org/kohsuke/args4j/spi/Messages.class
org/kohsuke/args4j/spi/Messages.properties
org/kohsuke/args4j/spi/Messages_de.properties
org/kohsuke/args4j/spi/Messages_en.properties
org/kohsuke/args4j/spi/Messages_ru.properties
org/kohsuke/args4j/spi/MethodSetter.class
org/kohsuke/args4j/spi/MultiFileOptionHandler.class
org/kohsuke/args4j/spi/MultiPathOptionHandler.class
org/kohsuke/args4j/spi/MultiValueFieldSetter.class
org/kohsuke/args4j/spi/OneArgumentOptionHandler.class
org/kohsuke/args4j/spi/OptionHandler.class
org/kohsuke/args4j/spi/OptionImpl.class
org/kohsuke/args4j/spi/Parameters.class
org/kohsuke/args4j/spi/PathOptionHandler.class
org/kohsuke/args4j/spi/PatternOptionHandler.class
org/kohsuke/args4j/spi/RestOfArgumentsHandler.class
org/kohsuke/args4j/spi/Setter.class
org/kohsuke/args4j/spi/Setters.class
org/kohsuke/args4j/spi/ShortOptionHandler.class
org/kohsuke/args4j/spi/StopOptionHandler.class
org/kohsuke/args4j/spi/StringArrayOptionHandler.class
org/kohsuke/args4j/spi/StringOptionHandler.class
org/kohsuke/args4j/spi/SubCommand.class
org/kohsuke/args4j/spi/SubCommandHandler$1.class
org/kohsuke/args4j/spi/SubCommandHandler.class
org/kohsuke/args4j/spi/SubCommands.class
org/kohsuke/args4j/spi/URIOptionHandler.class
org/kohsuke/args4j/spi/URLOptionHandler.class
org/kohsuke/args4j/spi/UuidOptionHandler.class

Thanks @ctrueden. Something else slipped in there with the branches that messed that up. Have a look at 0.2.4 now and see how that works for you.

1 Like

Thanks again @chris-allan. The 0.2.4 release looks good. I updated pom-scijava accordingly—not yet merged to master. Will be part of the impending pom-scijava 29.0.0 release.

ome:jxrlib-all:0.2.4 has now gone into Bio-Formats develop with the aforementioned PR having been merged. Noticed that the commit you mentioned, @ctrueden, is now missing? Are you still planning on doing something with pom-scijava directly?

There’s this commit on the mega-melt branch now:

1 Like