Hello world!
My goal is to use the NCTOOLBOX (https://github.com/nctoolbox/nctoolbox/wiki/) in a compiled MATLAB app.
Currently, I'm able to use the toolbox as intended when I run my code NOT from the compiled app.
However, when I try to perform the same tasks in the compiled app, it seems my scripts are struggling to find the right java drivers.
I'm relatively familiar with compiling apps using MATLAB. There are other java drivers which I successfuly use in the same compiled app. The approach I use for those java drivers is to add them in the 'settings' menu of the Application Compiler. For example, in the field "Additional parameters passed to the mcc:" I have a series of .jar files which I add like so (this driver is not the one causing the issue, it is just an example):
-a "C:\someFilePath\postgresql-42.2.12.jar"
^^ when I run my app NOT in its compiled state, the same java driver is added like so (and successfully ):
javaaddpath('C:\someFilePath\postgresql-42.2.12.jar');
The NCTOOLBOX script which is erroring on me is "ncdataset.m" and the exact line of code I'm erroring out on is:
obj.netcdf = ucar.nc2.dataset.NetcdfDataset.openDataset(url)
Here is the rest of the error readout (the above line of code shared is line 87 referenced in the following error readout):
=======================================================================
Error using ncdataset (line 87)
Java exception occurred:
java.io.IOException: java.lang.RuntimeException: java.lang.NoSuchMethodError: ucar.nc2.grib.grib2.Grib2IndexProto$GribIdSection.emptyIntList()Lcom/google/protobuf/Internal$IntList;
at ucar.nc2.NetcdfFile.open(NetcdfFile.java:401)
at ucar.nc2.dataset.NetcdfDataset.openProtocolOrFile(NetcdfDataset.java:831)
at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:479)
at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:461)
at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:442)
at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:426)
Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodError: ucar.nc2.grib.grib2.Grib2IndexProto$GribIdSection.emptyIntList()Lcom/google/protobuf/Internal$IntList;
at ucar.nc2.NetcdfFile.<init>(NetcdfFile.java:1634)
at ucar.nc2.NetcdfFile.open(NetcdfFile.java:798)
at ucar.nc2.NetcdfFile.open(NetcdfFile.java:398)
... 5 more
Caused by: java.lang.NoSuchMethodError: ucar.nc2.grib.grib2.Grib2IndexProto$GribIdSection.emptyIntList()Lcom/google/protobuf/Internal$IntList;
at ucar.nc2.grib.grib2.Grib2IndexProto$GribIdSection.<init>(Grib2IndexProto.java:140)
at ucar.nc2.grib.grib2.Grib2IndexProto$GribIdSection.<clinit>(Grib2IndexProto.java:1395)
at ucar.nc2.grib.grib2.Grib2Index.makeIdProto(Grib2Index.java:334)
at ucar.nc2.grib.grib2.Grib2Index.makeRecordProto(Grib2Index.java:286)
at ucar.nc2.grib.grib2.Grib2Index.makeIndex(Grib2Index.java:243)
at ucar.nc2.grib.GribIndex.readOrCreateIndexFromSingleFile(GribIndex.java:94)
at ucar.nc2.grib.collection.Grib2CollectionBuilder.makeGroups(Grib2CollectionBuilder.java:84)
at ucar.nc2.grib.collection.GribCollectionBuilder.createMultipleRuntimeCollections(GribCollectionBuilder.java:128)
at ucar.nc2.grib.collection.GribCollectionBuilder.createIndex(GribCollectionBuilder.java:120)
at ucar.nc2.grib.collection.GribCdmIndex.openGribCollectionFromDataFile(GribCdmIndex.java:825)
at ucar.nc2.grib.collection.GribCdmIndex.openGribCollectionFromDataFile(GribCdmIndex.java:804)
at ucar.nc2.grib.collection.GribCdmIndex.openGribCollectionFromRaf(GribCdmIndex.java:774)
at ucar.nc2.grib.collection.GribIosp.open(GribIosp.java:201)
at ucar.nc2.NetcdfFile.<init>(NetcdfFile.java:1610)
... 7 more
Error in cfdataset (line 59)
Error in ncgeodataset (line 74)
=======================================================================
Despite adding all the of .jar files supplied with the NCTOOLBOX, MATLAB appears to struggle to find / use them.
I notice that in the supplied NCTOOLBOX function called "ncugrid.m", there is a block of code which 'imports' various "ucar" related methods. I wonder if I need to set something up in my app compilation project definition which can take the place of this 'import' block.
{Example of 'import' block:
import ucar.ma2.Array;
import ucar.ma2.DataType;
import ucar.nc2.Attribute;
import ucar.nc2.Dimension;
import ucar.nc2.Variable;
import ucar.nc2.dataset.CoordinateSystem;
import ucar.nc2.dataset.NetcdfDataset;
import ucar.nc2.dataset.VariableDS;
import ucar.nc2.dt.ugrid.Cell;
import ucar.nc2.dt.ugrid.Edge;
import ucar.nc2.dt.ugrid.Face;
import ucar.nc2.dt.ugrid.Node;
import ucar.nc2.dt.ugrid.UGridDataset;
import ucar.nc2.dt.ugrid.geom.LatLonPoint2D;}
If anyone has insights / suggestions on what to try / solutions, they would be very much appreciated! Thank you in advance!