This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
> Hello, > > I have an HDF5 database supplied by an external party that I am trying to > read in Java using version 4.6.11 of the NetCDF library. When I open the file > using NetcdfFile.open (path) using a path returned from a JFileChooser and > for which File.exists() returns true, I get a NullPointerException as follows: > > Java.io.IOException : Java.lang.NullPointerException > NetcdfFile.java : 427, open () > NetcdfFile.java : 394, open () > NetcdfFile.java : 381, open () > NetcdfFile.java : 369, open () > > And when I do System.out.println (except.getMessage()); with the caught > exception, I get "null". > > I am not sure if the database has a field value that the NetCDF library is > not expecting. I was able to open the database using a validation tool, so > that Windows-specific application does not seem to have a problem opening the > HDF5 file. > > Is there any way that I can figure out what is causing this problem as the > information from the exception is particularly unenlightening? I did not > know if the source code for NetcdfFile.java was available for review anywhere > or whether this might be a bug in the library that is not checking to see if > a field is defined before accessing it? Any help would be most appreciated. > > Thank You, > -Creig Donnald Greetings Creig! The netCDF-Java library is on github, and can be found here: https://github.com/unidata/thredds Version 4.6.x is the master branch. Specifically, the code for NetcdfFile is here: https://github.com/Unidata/thredds/blob/master/cdm/src/main/java/ucar/nc2/NetcdfFile.java However, most likely, the error is occurring at the HDF5 IOSP layer: https://github.com/Unidata/thredds/tree/master/cdm/src/main/java/ucar/nc2/iosp/hdf5 It's hard to diagnose the exact problem without the file that is causing the error - is there any chance we could get a copy of it to take a look locally? Thank you! Sean Ticket Details =================== Ticket ID: ORC-296912 Department: Support netCDF Java Priority: Normal Status: Open =================== NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.