NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: [netcdf-java] Getting a NetcdfFile object from a dods url

On 10/03/2011 03:37 AM, Raymond Cramer wrote:
I am having a similar problem. From a browser I can return ASCII data, so the
OPeNDAP is working.
http://...../thredds/dodsC/vault/..._cf.nc.ascii?crs,depth[3599:1:3719][19199:1:19319]

If I try to access this through code, using http my log file fills up with
msgs which suggests I can't use http (or something else needs setting ;-)):


I believe that the only way to do this via the Java API is to open the unconstrained URL (http://...../thredds/dodsC/vault/..._cf.nc) and then use the API to request the hyperslab you want rather than trying to open the constrained URL.

Roland

Exception
http://....:8080/thredds/dodsC/vault/...._cf.nc?crs,depth[3600:1:3719][19200:1:19319],lat[3600:1:3719],lon[19200:1:19319]
java.lang.IllegalArgumentException: Invalid uri
'http://....:8080/thredds/dodsC/vault/...._cf.nc?crs,depth[3600:1:3719][19200:1:19319],lat[3600:1:3719],lon[19200:1:19319]':
Invalid query
        at
org.apache.commons.httpclient.HttpMethodBase.<init>(HttpMethodBase.java:222)
        at
org.apache.commons.httpclient.methods.HeadMethod.<init>(HeadMethod.java:94)
        at
ucar.unidata.io.http.HTTPRandomAccessFile.<init>(HTTPRandomAccessFile.java:92)
        at
ucar.unidata.io.http.HTTPRandomAccessFile.<init>(HTTPRandomAccessFile.java:78)
        at ucar.nc2.NetcdfFile.getRaf(NetcdfFile.java:300)
        at ucar.nc2.NetcdfFile.open(NetcdfFile.java:281)
        at ucar.nc2.dataset.NetcdfDataset.openFile(NetcdfDataset.java:335)
        at ucar.nc2.dataset.NetcdfDataset.openFile(NetcdfDataset.java:280)
        ...

If I try to use dods, I get a lot more msgs, it accesses the file, outputs
the header data but fails on the data (when the call becomes http again for
the DAS?):

[org.apache.commons.httpclient.HttpMethodBase] Resorting to protocol version
default close connection policy
[org.apache.commons.httpclient.HttpMethodBase] Should NOT close connection,
using HTTP/1.1
[org.apache.commons.httpclient.HttpConnection] enter
HttpConnection.isResponseAvailable()
[org.apache.commons.httpclient.HttpConnection] enter
HttpConnection.releaseConnection()
[org.apache.commons.httpclient.HttpConnection] Releasing connection back to
connection manager.
[org.apache.commons.httpclient.MultiThreadedHttpConnectionManager] enter
HttpConnectionManager.releaseConnection(HttpConnection)
[org.apache.commons.httpclient.MultiThreadedHttpConnectionManager] Freeing
connection, hostConfig=HostConfiguration[host=http://....:8080]
[org.apache.commons.httpclient.MultiThreadedHttpConnectionManager] enter
HttpConnectionManager.ConnectionPool.getHostPool(HostConfiguration)
[org.apache.commons.httpclient.util.IdleConnectionHandler] Adding connection
at: ........
[org.apache.commons.httpclient.MultiThreadedHttpConnectionManager] Notifying
no-one, there are no waiting threads
[ucar.nc2.dods.DODSNetcdfFile] DODSNetcdfFile
dods://....:8080/thredds/dodsC/vault/...._cf.nc?crs,depth[3600:1:3719][19200:1:19319],lat[3600:1:3719],lon[19200:1:19319]
java.lang.IllegalArgumentException: Invalid uri
'http://....:8080/thredds/dodsC/vault/...._cf.nc.das?crs,depth[3600:1:3719][19200:1:19319],lat[3600:1:3719],lon[19200:1:19319]':
Invalid query
        at
org.apache.commons.httpclient.HttpMethodBase.<init>(HttpMethodBase.java:222)
        at
org.apache.commons.httpclient.methods.GetMethod.<init>(GetMethod.java:89)
        at opendap.dap.DConnect2.openConnection(DConnect2.java:205)
        at opendap.dap.DConnect2.getDAS(DConnect2.java:399)
        at ucar.nc2.dods.DODSNetcdfFile.<init>(DODSNetcdfFile.java:186)
        at ucar.nc2.dataset.NetcdfDataset.openDODS(NetcdfDataset.java:379)
        at ucar.nc2.dataset.NetcdfDataset.openFile(NetcdfDataset.java:316)
        at ucar.nc2.dataset.NetcdfDataset.openFile(NetcdfDataset.java:280)
       .....
ERROR [uk.ac.bodc.Netcdf_Utils] trying to open
dods://....:8080/thredds/dodsC/vault/...._cf.nc?crs,depth[3600:1:3719][19200:1:19319],lat[3600:1:3719],lon[19200:1:19319]
java.io.FileNotFoundException: Cant open
dods://....:8080/thredds/dodsC/vault/...._cf.nc?crs,depth[3600:1:3719][19200:1:19319],lat[3600:1:3719],lon[19200:1:19319]
or as DODS
dods://....:8080/thredds/dodsC/vault/...._cf.nc?crs,depth[3600:1:3719][19200:1:19319],lat[3600:1:3719],lon[19200:1:19319]
Invalid uri
'http://....:8080/thredds/dodsC/vault/...._cf.nc.das?crs,depth[3600:1:3719][19200:1:19319],lat[3600:1:3719],lon[19200:1:19319]':
Invalid query
        at ucar.nc2.dataset.NetcdfDataset.openDODS(NetcdfDataset.java:381)
        at ucar.nc2.dataset.NetcdfDataset.openFile(NetcdfDataset.java:316)
        at ucar.nc2.dataset.NetcdfDataset.openFile(NetcdfDataset.java:280)
       ....

I am accessing this through inFile = NetcdfDataset.openFile(inFileName,
null);

I hope I haven't broken any rules for the length of this msg, hopefully
there's sufficient info that someone recognises the problem.

--
View this message in context: 
http://netcdf-java.1577316.n2.nabble.com/Getting-a-NetcdfFile-object-from-a-dods-url-tp6677113p6854222.html
Sent from the NetCDF-Java mailing list archive at Nabble.com.

_______________________________________________
netcdf-java mailing list
netcdf-java@xxxxxxxxxxxxxxxx
For list information or to unsubscribe, visit: 
http://www.unidata.ucar.edu/mailing_lists/



  • 2011 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: