Unidata / netcdf-java

The Unidata netcdf-java library
https://docs.unidata.ucar.edu/netcdf-java/current/userguide/index.html
BSD 3-Clause "New" or "Revised" License
142 stars 69 forks source link

NoSuchMethodError for NetCDF Builder [VERSION]: 5.5.3 #1224

Closed nhandwerk closed 7 months ago

nhandwerk commented 1 year ago

Versions impacted by the bug

v5.x

What went wrong?

When calling the following line NetcdfFormatWriter.createNetNetcdfX a no such method would occur. It happened if called using "createNewNetcdf3" : NetcdfFormatWriter.Builder nc4builder = NetcdfFormatWriter.createNewNetcdf3("temp.nc");

or with "createNewNetcdf4" NetcdfFormatWriter.Builder nc4builder = NetcdfFormatWriter.createNewNetcdf4(NetcdfFileFormat.NETCDF4, "temp.nc", null);

Below are the relevant imports called:

import ucar.nc2.write.NetcdfFormatWriter.Builder;
import ucar.nc2.write.NetcdfFormatWriter;
import ucar.nc2.Dimension;
import ucar.nc2.write.NetcdfFileFormat;
import ucar.nc2.*;

The jar file that is in my lib directory is: netcdfAll-5.5.3,jar which I downloaded from here https://downloads.unidata.ucar.edu/netcdf-java/

Current build is using Ant but have also build using Maven and ran into the same issue.

Relevant stack trace

java.lang.NoSuchMethodError: 'ucar.nc2.Group$Builder ucar.nc2.Group.builder()'
java.lang.NoSuchMethodError: 'ucar.nc2.Group$Builder ucar.nc2.Group.builder()'
    at ucar.nc2.write.NetcdfFormatWriter$Builder.<init>(NetcdfFormatWriter.java:98)
    at ucar.nc2.write.NetcdfFormatWriter.builder(NetcdfFormatWriter.java:84)
    at ucar.nc2.write.NetcdfFormatWriter.createNewNetcdf3(NetcdfFormatWriter.java:66)

Relevant log messages

No response

If you have an example file that you can share, please attach it to this issue.

If so, may we include it in our test datasets to help ensure the bug does not return once fixed? Note: the test datasets are publicly accessible without restriction.

Yes

Code of Conduct

mnlerman commented 1 year ago

Hello, I ran a quick test and I'm having a hard time reproducing the error that your seeing. I did a cursory google search of the java.lang.NoSuchMethodError and found that it's possible that there is a version mismatch between the compile time and runtime dependancies. Is it possible that you have another version of the jar file hanging around somewhere that's causing the error?