Reputation: 2431
I've been attempting to upgrade the version of Java (currently 8u144) used in an application connecting to an Oracle 12.2 database using ojdbc8. My latest attempt to update to 8u201 fails with the following error:
Exception in thread "main" java.lang.NullPointerException
at oracle.net.jndi.JndiAttrs.getAttrs(JndiAttrs.java:215)
at oracle.net.resolver.AddrResolution.<init>(AddrResolution.java:237)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:233)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1438)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:518)
at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:688)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:39)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:691)
at oracle.jdbc.pool.OracleDataSource.getPhysicalConnection(OracleDataSource.java:384)
at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:273)
at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:198)
at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:176)
at Main.main(Main.java:22)
I'm using an LDAP url with the syntax supported and documented similar to the following:
"jdbc:oracle:thin:@ldaps://ldap.example.com:7777/sales,cn=OracleContext,dc=com"
Although my question is similar to the following question, I am not using Hibernate and this question doesn't seem to really answer/address what might be the underlying issue.
Unable to get db connection after Java 8 upgrade
To simplify everything, I have reduced my tests to a simple project using only ojdbc8 and something like the following:
String url = "jdbc:oracle:thin:@ldaps://....";
OracleDataSource ods = new OracleDataSource();
ods.setUser("indiana");
ods.setPassword("thedoctor");
ods.setURL(url);
Connection conn = ods.getConnection();
PreparedStatement st = conn.prepareStatement("select * from world where temple = 'doom'");
ResultSet rs = st.executeQuery();
while(rs.next()) {
System.out.println(rs.getString("last"));
}
If I switch Java to 8u144 using the exact same code and configuration, the above works just fine. I'm at a loss...
UPDATE I've narrowed the issue down some, and discovered that the break occurs at Java 8u171. I'm looking into the release notes for that version and anything else I can find now.
Upvotes: 4
Views: 2368
Reputation: 149
Looks like the SSL handshake is failing while creating the LDAPS connection. Running the test program with the java net debugging option will help in analysing the issue. Add this option -Djavax.net.debug=all for running your test program and debug output will contain the SSL debug logs which would be useful in identifying the cause. JDK 8u171 has some security related changes.
(SSL Debug :: https://docs.oracle.com/javase/7/docs/technotes/guides/security/jsse/ReadDebug.html)
Upvotes: 2