I have a separate project, which I set up to test the inner workings of different operators, but I seem to be having problems trying to set a single source product, like this:
Product product1 = this.reader1.readProductNodes(file1, null);
this.tileHeight = 560;
this.tileWidth = 404;
Operator operator = new CoherenceOp();
operator.setSourceProduct(product1);
//((CoherenceOp) operator).sourceProduct = product1;
operator.initialize();
the commented out part is what I used to forcefully set source products after setting their field public in the operator. The operator works after this, but I suspect that a bug that surfaces later is connected to it.
The code produces the following error:
java.lang.NullPointerException
org.esa.snap.core.gpf.OperatorException: java.lang.NullPointerException
problems reading nodes
at org.esa.snap.engine_utilities.gpf.OperatorUtils.catchOperatorException(OperatorUtils.java:415)
at operators.CoherenceOp.initialize(CoherenceOp.java:227)
at OperatorHandler.coherenceEstimation(OperatorHandler.java:102)
at Main.main(Main.java:9)
Caused by: java.lang.NullPointerException
at org.esa.snap.engine_utilities.datamodel.AbstractMetadata.getAbstractedMetadata(AbstractMetadata.java:633)
at operators.CoherenceOp.initialize(CoherenceOp.java:198)
… 2 more
The error was achieved on intellij. The project is only composed of the operator and the code that starts it up. I have more of such projects, but all of those use setSourceProducts in plural, which works just fine.
Is there anything that I need to do with an operator before setting source product?
using the following pom.xml file:
<?xml version=“1.0” encoding=“UTF-8”?>
<project xmlns=“http://maven.apache.org/POM/4.0.0”
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=“http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”>
<modelVersion>4.0.0</modelVersion>
<groupId>erik.soekov</groupId>
<artifactId>coherence-play</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<snap.version>7.0.0-SNAPSHOT</snap.version>
<s1tbx.version>7.0.0-SNAPSHOT</s1tbx.version>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.esa.snap</groupId>
<artifactId>snap-core</artifactId>
<version>{snap.version}</version>
        </dependency>
        <dependency>
            <groupId>org.esa.snap</groupId>
            <artifactId>snap-geotiff</artifactId>
            <version>{snap.version}</version>
</dependency>
<dependency>
<groupId>org.esa.snap</groupId>
<artifactId>snap-gpf</artifactId>
<version>{snap.version}</version>
        </dependency>
        <dependency>
            <groupId>org.esa.s1tbx</groupId>
            <artifactId>s1tbx-commons</artifactId>
            <version>{s1tbx.version}</version>
</dependency>
<dependency>
<groupId>org.esa.s1tbx</groupId>
<artifactId>s1tbx-op-insar</artifactId>
<version>{s1tbx.version}</version>
        </dependency>
        <dependency>
            <groupId>org.esa.snap</groupId>
            <artifactId>snap-engine-utilities</artifactId>
            <version>{s1tbx.version}</version>
</dependency>
<dependency>
<groupId>org.jocl</groupId>
<artifactId>jocl</artifactId>
<version>2.0.1</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>snap-repo-public</id>
<name>Public Maven Repository for SNAP</name>
<url>http://nexus.senbox.net/nexus/content/repositories/public/</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>nbm-maven-plugin</artifactId>
<configuration>
<publicPackages>
<publicPackage>org.esa.s1tbx.*</publicPackage>
</publicPackages>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>ee.cgi.malbolge.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>