Handshaker.algorithmConstraints

2019-08-12 16:35发布

问题:

I am running the code Jetty provided for HTTP/2 client https://github.com/eclipse/jetty.project/blob/master/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/Client.java

And I come across such a problem

INFO::main: Logging initialized @166ms
2015-09-04 22:48:46.253:WARN:oejut.QueuedThreadPool:qtp1342443276-11: 
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:771)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:281)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:969)
at sun.security.ssl.Handshaker$1.run(Handshaker.java:909)
at sun.security.ssl.Handshaker$1.run(Handshaker.java:906)
at java.security.AccessController.doPrivileged(Native Method)
at sun.security.ssl.Handshaker$DelegatedTask.run(Handshaker.java:1359)
at org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.fill(SslConnection.java:613)
at org.eclipse.jetty.io.NegotiatingClientConnection.fill(NegotiatingClientConnection.java:96)
at org.eclipse.jetty.io.NegotiatingClientConnection.onFillable(NegotiatingClientConnection.java:82)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:245)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:192)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:245)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
at java.lang.Thread.run(Thread.java:745)
2015-09-04 22:48:46.253:WARN:oejut.QueuedThreadPool:qtp1342443276-11: Unexpected thread death: org.eclipse.jetty.util.thread.QueuedThreadPool$3@453be99c in qtp1342443276{STARTED,8<=8<=200,i=6,q=0}
Exception in thread "main" java.util.concurrent.TimeoutException
at org.eclipse.jetty.util.FuturePromise.get(FuturePromise.java:130)
at org.eclipse.jetty.http2.client.Client.main(Client.java:60)

Anyone know how to solve it? please

回答1:

To quote @sbordet: from your other question on the same topic.

Make sure:

  1. that you have the ALPN boot jar in your bootclasspath;
  2. that the server you are contacting supports HTTP/2;
  3. if using TLS, that the server you are contacting sends a valid, verifiable certificate.

Enable DEBUG logging level for the org.eclipse.jetty category, and you will have a lot of information about what's going on.

Also, set ALPN.debug=true to understand if ALPN worked correctly

In short, you NEED ALPN to have any hope in getting HTTP/2 to work (It's a spec requirement)

And the only way to have ALPN support, is to setup the -Xbootclasspath entry for your Java VM to load the ALPN support jar (like @sbordet mentioned)