Welcome to the BEAM Forum!

We encourage you to sign in our forum and participate in the BEAM community. The forum is maintained by the BEAM project team who will most likely answer your questions within 24 hours (except during common holidays) - if not done by other community members. Collaborate, share your knowledge and learn from other users!

If you don't find what you are looking for, please also consider the following external forums:

Combination View Flat View Tree View
Threads [ Previous | Next ]
org/geotools/factory/Hints$Key error
toggle
org/geotools/factory/Hints$Key error
.n1 hdf meris
12/28/18 5:46 PM
package org.acme.snap.tutorials;

import com.bc.ceres.core.ProgressMonitor;
import org.esa.snap.core.dataio.ProductIO;
import org.esa.snap.core.datamodel.Band;
import org.esa.snap.core.datamodel.Product;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

/*
Example taken from the tutorial given at Sentinel-3 OLCI/SLSTR and MERIS/(A)ATSR workshop 2012.
See http://www.brockmann-consult.de/cms/web/beam/tutorials

*/

public class QuicklookGenerator {

public static void main(String[] args) {
try {
Product product = ProductIO.readProduct("/Users/Satellite data/MERIS-Test-Data/MER_RR__1P_TEST.N1");
// Product product = ProductIO.readProduct(args[0]);
Band band = product.getBand("radiance_13");
BufferedImage rgbImage = band.createRgbImage(ProgressMonitor.NULL);
ImageIO.write(rgbImage, "PNG", new File(product.getName() + ".png"));
} catch (IOException e) {
System.err.println("Error: " + e.getMessage());
}
}
}

Run the above program in the NetBeans 8.2 environment on a Mac machine, got the following error message, any help would be much appreciated

run:
Exception in thread "main" java.lang.NoClassDefFoundError: org/geotools/factory/Hints$Key
at org.esa.snap.core.dataio.ProductIO.getProductReaderForInput(ProductIO.java:253)
at org.esa.snap.core.dataio.ProductIO.readProductImpl(ProductIO.java:214)
at org.esa.snap.core.dataio.ProductIO.readProduct(ProductIO.java:186)
at org.acme.snap.tutorials.QuicklookGenerator.main(QuicklookGenerator.java:24)
Caused by: java.lang.ClassNotFoundException: org.geotools.factory.Hints$Key
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 4 more
/Users/.../Library/Caches/NetBeans/8.2/executor-snippets/run.xml:53: Java returned: 1
BUILD FAILED (total time: 1 second)
Flag Flag
RE: org/geotools/factory/Hints$Key error
1/7/19 10:46 AM as a reply to Yaxin Bi.
It seems that your project setup is not complete. You probably need to add dependencies. Have you used Maven to create the project?
Also, you should post your question in the STEP Forum, because you are using SNAP and not BEAM.
Flag Flag
RE: org/geotools/factory/Hints$Key error
1/11/19 11:04 AM as a reply to Marco Peters.
Thanks for offering possible answer, I am not able to create an account in STEP forum.

I have tried with Maven in NetBeans, but got the following error, any suggestion would be much appreciated

------------------------------------------------------------------------
Building mavenproject1 1.0-SNAPSHOT
------------------------------------------------------------------------

--- exec-maven-plugin:1.2.1:exec (default-cli) @ mavenproject1 ---
Exception in thread "main" java.lang.NoClassDefFoundError: org/esa/snap/core/dataio/ProductIO
at QuicklookGenerator.main(QuicklookGenerator.java:34)
Caused by: java.lang.ClassNotFoundException: org.esa.snap.core.dataio.ProductIO
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 0.651s
Finished at: Tue Jan 08 23:25:54 GMT 2019
Final Memory: 7M/309M
------------------------------------------------------------------------
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project mavenproject1: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

POM.xml
<?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>com.mycompany</groupId>
<artifactId>mavenproject1</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>snep.jdk</groupId>
<artifactId>sentinel</artifactId>
<version>1.5.0</version>
<scope>system</scope>
<systemPath>/Users/projects/Maven-rr/mavenproject1/src/lib/org-esa-snap-ceres-core.jar</systemPath>
</dependency>

<dependency>
<groupId>snep.jdk1</groupId>
<artifactId>sentinel1</artifactId>
<version>1.5.0</version>
<scope>system</scope>
<systemPath>/Users/projects/Maven-rr/mavenproject1/src/lib/org-esa-snap-snap-core.jar</systemPath>
</dependency>

</dependencies>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

</project>
Flag Flag
RE: org/geotools/factory/Hints$Key error
1/14/19 12:00 PM as a reply to Yaxin Bi.
You will need several more dependencies. For example all ceres modules not only the core.
And from SNAP you will probably need snap-gpf too. And depending on what you are doing you will need other modules.
You can also have a look at wiki page. There it is described how jars can be bundled.
Flag Flag