(java) Unkown operator exception when running an executable jar


#1

Hello all,

I’ve been using a java maven project I developed in NetBeans which calls on the operators I need from SNAP and S1TBX to do the processing I need. I usually run it from the IDE with no problems, but I’m trying to use it on another computer (specifically a HPC system).

The program is here : https://gitlab.com/sdufourbeausejour/java-snap , in branch AddMultiTemporalClassif.

I’ve succeeded in building a jar file containing all dependencies by adding the maven-assembly-plugin to the pom file.

All operations which run on librairies like java.io or java.utils succeed, as well as reading a .dim product, but we run into a problem with the first call to CreateProduct :

$ java -jar java-snap-jar-with-dependencies.jar "input.txt" Input
... (info on the products that have been read)
Exception in thread "main" org.esa.snap.core.gpf.OperatorException : Unkown operator 'Subset'. Note that operator aliases are case-sensitive.
   at org.esa.snap.core.gpf.GPF.CreateProduct

Your help would be greatly appreciated, I’m participating in a hackathon and hope to get it working before tomorrow !

Kind regards,

SDB


#2

I fixed this by adding references to all the SNAP operators I use in my project’s META-INF.services/org.esa.snap.core.gpf.OperatorSpi file :

com.batchprocessing.java.snap.MyPolarimetricParametersOp$Spi
com.batchprocessing.java.snap.MyPolarimetricParametersDualOp$Spi
org.esa.snap.core.gpf.common.ReadOp$Spi
org.esa.snap.core.gpf.common.MergeOp$Spi
org.esa.snap.core.gpf.common.WriteOp$Spi
org.esa.snap.core.gpf.common.MosaicOp$Spi
org.esa.snap.core.gpf.common.SubsetOp$Spi
org.esa.snap.core.gpf.common.WriteRGBOp$Spi
org.esa.snap.core.gpf.common.PassThroughOp$Spi
org.esa.snap.core.gpf.common.ProductSetReaderOp$Spi
org.esa.snap.core.gpf.common.BandMathsOp$Spi
org.esa.snap.core.gpf.common.reproject.ReprojectionOp$Spi
org.esa.snap.core.gpf.common.resample.ResamplingOp$Spi
org.esa.snap.core.gpf.common.ImportVectorOp$Spi
org.esa.s1tbx.insar.gpf.coregistration.CreateStackOp$Spi

I hope this can be of use to someone !


#3

Good to hear that you found a solution, though this does not look like the ideal way. I’ve seen that you do not have a dependency to snap-gpf set. Maybe including it would fix the problem, too.


#4

Thank you for your answer !

I tried to use your solution. SNAP GPF is already included as a dependency in the project; it is listed under the Dependency folder in Netbeans. However, it doesn’t appear in the pom.xml (why ?). So I added it like this :

<dependency>
    <groupId>org.esa.snap</groupId>
    <artifactId>snap-gpf</artifactId>
    <version>6.0.0-SNAPSHOT</version>
</dependency>

and removed the lines I had added to the MAIN-INF.services/org.esa.snap.core.gpf.OperatorSpi file.

This configuration gives me the same error as before.

I’d be eager to correct it properly, particulary since I’m running into other issues that may be caused by the same fundamental missing link.

Any suggestion ?


#5

The problem here seems to be mainly maven-related. You could try to set up a descriptor ( https://maven.apache.org/guides/mini/guide-assemblies.html ) or have a look at this solution: https://stackoverflow.com/a/4323501 .


#6

Thank you for your help @TonioF, I’ve got it working now. I used the maven-dependency-plugin with the maven-jar-plugin; I chose to have a light executable jar with all the dependencies in a lib/ directory. This post shows a relevent excerpt from my pom.xml file. I only kept the two lines referencing my new operators in my OperatorSpi file. The complete files can be found in the project on gitlab.


#7

Good to hear, thanks for sharing your solution!