1

I am developing an Application which uses Pushy with HTTP/2 access via ALPN to send Push Notifications to Apple iPhones.

For that I have configured the JVM to use ALPN as requested with the following VM Argument.

-Xbootclasspath/p:<Path To ALPN JAR>

This connection to Apple Push Notification Server works fine.

But In the same Application I have a MSSQL Datasource connecting to the Database via MSSQL Jdbc Driver. But when it tries to connect to the MSSQL it throws the following Error:

java.lang.IllegalAccessError: tried to access field sun.security.ssl.Handshaker.algorithmConstraints from class sun.security.ssl.ClientHandshaker

Can anyone help me with this or point me in the correct direction.

Full Stack Trace

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalAccessError: tried to access field sun.security.ssl.Handshaker.algorithmConstraints from class sun.security.ssl.ClientHandshaker
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
    ... 58 more
Caused by: java.lang.IllegalAccessError: tried to access field sun.security.ssl.Handshaker.algorithmConstraints from class sun.security.ssl.ClientHandshaker
    at sun.security.ssl.ClientHandshaker.serverKeyExchange(ClientHandshaker.java:778)
    at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:285)
    at sun.security.ssl.Handshaker.processLoop(Handshaker.java:969)
    at sun.security.ssl.Handshaker.process_record(Handshaker.java:904)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1050)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1363)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1391)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1375)
    at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1618)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1323)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
    at com.microsoft.sqlserver.jdbc.SQLServerDataSource.getConnectionInternal(SQLServerDataSource.java:621)
    at com.microsoft.sqlserver.jdbc.SQLServerDataSource.getConnection(SQLServerDataSource.java:57)
    at com.zaxxer.hikari.pool.BaseHikariPool.addConnection(BaseHikariPool.java:373)
    at com.zaxxer.hikari.pool.BaseHikariPool.initializeConnections(BaseHikariPool.java:469)
    at com.zaxxer.hikari.pool.BaseHikariPool.<init>(BaseHikariPool.java:162)
    at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:61)
    at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:49)
    at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:78)

Removing the VM Argument fixed the Datasource Issue but the ALPN connection fails.

UPDATE

Jetty's ALPN-Boot library will override the package sun.security.ssl Which is also available in jsse.jar (Which means is a JVM core class) This overriding makes the dataSource fail because MSSQL Server is not a HTTP2 Server

This is why I got

java.lang.IllegalAccessError: tried to access field sun.security.ssl.Handshaker.algorithmConstraints from class sun.security.ssl.ClientHandshaker

Is there anyway I could use Both HTTP2 and HTTP together?

shazin
  • 21,379
  • 3
  • 54
  • 71
  • Does this answer help? http://stackoverflow.com/questions/32401050/handshaker-algorithmconstraints – Frederik Deweerdt Sep 16 '16 at 03:26
  • @FrederikDeweerdt Thanks for your comment but this is not the solution. As I have to access both HTTP2 and HTTP Servers from the same code. – shazin Sep 29 '16 at 08:31

1 Answers1

1

I managed to get rid of this problem by using the jetty-alpn-agent

shazin
  • 21,379
  • 3
  • 54
  • 71