[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDFJava #RAN-171087]: "javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection" for proxy connections



You can test if HTTPSession is defined by un-jarring the netcdf-java jar file
and seeing it HTTPSession.class is present.

It looks more to me like the HTTPSession constructor is failing.
Did you include the whole exception stack trace for that;
I would have expected a "caused by" in the stack trace.

I tested that url without using a proxy and it worked, so my
speculation is that I did not do the proxy handling correctly.

As for the slf4j, I have no idea. Christian?

> Hello Dennis,
> 
> firstly, thanks for the support.
> 
> I tried to use the provided file "netcdfAll-4.6.11-20170925.225407-18.jar" 
> with Matlab and Java.
> 
> 
> Using MatLab:
> 
> The netDCF java API is used by a Matlab toolbox called nctoolbox, which uses 
> the netDCF java methods for the real work.
> The purpose is to access CFSR climate model data via OPeNDAP from grib2 files.
> 
> 
> I import the java methods successfully using
> javaaddpath('Path\to\netcdfAll-4.6.11-20170925.225407-18.jar ')
> 
> Calling "javaclasspath" confirmes that the netCDF jar-file is on the java 
> path of Matlab.
> 
> First I tried to set the proxy settings using the line 
> "ucar.httpservices.HTTPSession.setGlobalProxy(proxyname,port)".
> This call resulted in an unrecognized class error.
> First I thought this is because the abovementioned import went wrong.
> 
> However I tried to access a remote dataset at Nomads: 
> 'https://nomads.ncdc.noaa.gov/thredds/dodsC/modeldata/cmd_pgbh/2008/200811/20081101/pgbh00.gdas.2008110100.grb2'
> using the matlab call
> 
> " url = 
> 'https://nomads.ncdc.noaa.gov/thredds/dodsC/modeldata/cmd_pgbh/2008/200811/20081101/pgbh00.gdas.2008110100.grb2';
> obj.netcdf = ucar.nc2.dataset.NetcdfDataset.openDataset(url);"
> 
> The process ends with an initializing error during a call of 
> "ucar.httpservices.HTTPSession":
> 
> "    Java exception occurred:
> java.lang.NoClassDefFoundError: Could not initialize class 
> ucar.httpservices.HTTPSession
> 
> at ucar.httpservices.HTTPFactory.newSession(HTTPFactory.java:57)
> 
> at ucar.httpservices.HTTPMethod.<init>(HTTPMethod.java:220)
> 
> at ucar.httpservices.HTTPMethod.<init>(HTTPMethod.java:194)
> 
> at ucar.httpservices.HTTPFactory.Get(HTTPFactory.java:127)
> 
> at ucar.nc2.dataset.NetcdfDataset.checkIfDods(NetcdfDataset.java:910)
> 
> at ucar.nc2.dataset.NetcdfDataset.disambiguateHttp(NetcdfDataset.java:827)
> 
> at ucar.nc2.dataset.NetcdfDataset.openOrAcquireFile(NetcdfDataset.java:706)
> 
> at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:427)
> 
> at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:410)
> 
> at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:395)
> 
> at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:382) "
> 
> 
> The class-method "ucar.nc2.dataset.NetcdfDataset.openDataset()" seems to be 
> recognized.
> The class-method "ucar.httpservices.HTTPSession.setGlobalProxy()" and the 
> class of "ucar.httpservices.HTTPSession" apparently not.
> 
> 
> 
> Using Java:
> 
> I tried to verify if the same error also appears without using Java without 
> MatLab.
> 
> The sample code I used is:
> 
> "import ucar.nc2.dataset.NetcdfDataset;
> import ucar.httpservices.HTTPSession;
> import java.lang.Throwable;
> 
> public class JavaProxyTest {
> public static void main( String[] args ) {
> NetcdfDataset ncd = null;
> String url;
> url = 
> "https://nomads.ncdc.noaa.gov/thredds/dodsC/modeldata/cmd_pgbh/2008/200811/20081101/pgbh00.gdas.2008110100.grb2";;
> try {
> ncd = NetcdfDataset.openDataset(url);
> } catch(Exception e) {
> e.printStackTrace();
> } finally {
> try {
> ncd.close();
> } catch(Exception e) {
> e.printStackTrace();
> }
> }
> }
> }"
> 
> To run this code I needed to import: netcdfAll-4.6.11-20170925.225407-18.jar 
> and slf4j-log4j12-1.7.25.jar.
> Without the slf4j-jar-file the error "SLF4J: Failed to load class 
> "org.slf4j.impl.StaticLoggerBinder"" appeared.
> 
> The code compiles using:
> "javac -cp 
> ".;netcdfAll-4.6.11-20170925.225407-18.jar;slf4j-log4j12-1.7.25.jar;" 
> .\JavaProxyTest.java"
> 
> Running the data access using
> "java -cp 
> ".;netcdfAll-4.6.11-20170925.225407-18.jar;slf4j-log4j12-1.7.25.jar" 
> JavaProxyTest"
> leads to the error:
> 
> "Failed to instantiate SLF4J LoggerFactory
> Reported exception:
> java.lang.NoClassDefFoundError: org/apache/log4j/Level
> at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
> at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
> at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:412)
> at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357)
> at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)
> at ucar.nc2.NetcdfFile.<clinit>(NetcdfFile.java:95)
> at JavaProxyTest.main(JavaProxyTest.java:16)
> Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Level
> at java.net.URLClassLoader.findClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> ... 7 more
> java.lang.NullPointerException
> at JavaProxyTest.main(JavaProxyTest.java:21)
> Exception in thread "main" java.lang.NoClassDefFoundError: 
> org/apache/log4j/Level
> at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
> at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
> at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:412)
> at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357)
> at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)
> at ucar.nc2.NetcdfFile.<clinit>(NetcdfFile.java:95)
> at JavaProxyTest.main(JavaProxyTest.java:16)
> Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Level
> at java.net.URLClassLoader.findClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> ... 7 more"
> 
> My Java version is:
> java version "1.8.0_144"
> Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
> Java HotSpot(TM) Client VM (build 25.144-b01, mixed mode)
> 
> So the Matlab error seems to be caused by "ucar.httpservices.HTTPSession" 
> while in Java " org.slf4j.LoggerFactory" seems not to find a class definition 
> or something.
> 
> Could both errors be related ?
> 
> Best regards
> Marius
> 
> 
> --
> Dipl.-Phys. Marius Kist
> Fraunhofer-Institut für Optronik, Systemtechnik und Bildauswertung IOSB
> Abteilung Signatorik
> Gutleuthausstr. 1, 76275 Ettlingen, Germany
> Phone +49 7243 992-223
> address@hidden
> www.iosb.fraunhofer.de/sig
> 
> -----Ursprüngliche Nachricht-----
> Von: Unidata netCDF Java Support [mailto:address@hidden]
> Gesendet: Montag, 25. September 2017 22:38
> An: Kist, Marius
> Cc: address@hidden
> Betreff: [netCDFJava #RAN-171087]: "javax.net.ssl.SSLException: Unrecognized 
> SSL message, plaintext connection" for proxy connections
> 
> There is a bug in the HTTPSession code.
> I have fixed the bug; see github pull request
> https://github.com/Unidata/thredds/pull/924
> 
> It is unknown if this fixes the bug reported here because I have no ability 
> to test.
> 
> > > Hello Dennis,
> > >
> > > thank you for the quick reply.
> > >
> > > I tried to change to netCDF-java version 4.6.10
> > > (http://artifacts.unidata.ucar.edu/content/repositories/unidata-rele
> > > ases/edu/ucar/netcdfAll/4.6.10/netcdfAll-4.6.10.jar)
> > >
> > > I tried to set the proxy settings by reading them from the system
> > > settings using 
> > > "org.apache.http.impl.client.HttpClientBuilder.create().useSystemProperties().build()"
> > >
> > > The resulting error is:
> > > Java exception occurred:
> > > "java.lang.NoSuchFieldError: INSTANCE
> >
> > Remember that I do not entirely trust the proxy API we have because of
> > our inability to test it.
> > In looking at the code, there may be a bug that I need to track down
> > that is preventing the proxy info from being used.
> >
> > Having said that.
> > There are at least two ways to set the proxy.
> > 1. add flag -Dproxyurl=http://<host>:<port> to the java command.
> >
> > 2. add flags -Dhttps.proxyHost=<hostname> -Dhttps.proxyPort=<port> to
> > the java command
> >
> >
> >
> >
> >
> > =Dennis Heimbigner
> > Unidata
> >
> 
> =Dennis Heimbigner
> Unidata
> 
> 
> Ticket Details
> ===================
> Ticket ID: RAN-171087
> 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.
> 
> 
> 

=Dennis Heimbigner
  Unidata


Ticket Details
===================
Ticket ID: RAN-171087
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.