我已经使用Jetty和SPDY返回到JDK8,我看到现在Jetty 9.2支持ALPN协议而不是NPN(请参阅我的问题How to run Jetty with SPDY on JDK8?)。所以我设置bootclasspath
:
java -Xbootclasspath/p:c:/jars/alpn-boot/alpn-boot-8.0.0.v2014031 ...
但现在我有例外:
Exception in thread "xyz.server" java.lang.NoClassDefFoundError:
org/eclipse/jetty/npn/NextProtoNego$ServerProvider
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
...
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.eclipse.jetty.spdy.server.http.HTTPSPDYServerConnector.<init>(HTTPSPDYServerConnector.java:63)
at org.eclipse.jetty.spdy.server.http.HTTPSPDYServerConnector.<init>(HTTPSPDYServerConnector.java:53)
at org.eclipse.jetty.spdy.server.http.HTTPSPDYServerConnector.<init>(HTTPSPDYServerConnector.java:43)
at xyz.my.my_httpsrv_jetty.startHTTPSServer(my_httpsrv_jetty.java:359)
...
我使用java version "1.8.0_05"
和jetty 9.2.2.v20140723。
我在WinXP上使用JDK 1.7和alpn-boot-7.0.0.v20140317.jar
时遇到的错误,如果我从-Xbootclasspath/p:c:/jars/npn-boot/npn-boot-1.1.7.v20140316.jar
这个例子在我的代码中指向:
SSLconnector = new HTTPSPDYServerConnector(server, sslContextFactory);
似乎即使使用ALPN jetty也需要来自npn-boot的类。 这是一个错误还是我做错了什么?
答案 0 :(得分:4)
HTTPSPDYServerConnector
未更新为ALPN,目前硬编码使用NPN。
为了将ALPN与SPDY一起使用,您必须以这种方式配置ServerConnector
:
SslContextFactory sslContextFactory = new SslContextFactory();
HttpConfiguration httpConfig = new HttpConfiguration();
SslConnectionFactory ssl = new SslConnectionFactory(sslContextFactory, "alpn");
ALPNServerConnectionFactory alpn = new ALPNServerConnectionFactory("spdy/3", "http/1.1");
alpn.setDefaultProtocol("http/1.1");
HTTPSPDYServerConnectionFactory spdy = new HTTPSPDYServerConnectionFactory(SPDY.V3, httpConfig);
HttpConnectionFactory http = new HttpConnectionFactory(httpConfig);
Server server = new Server();
ServerConnector connector = new ServerConnector(server, new ConnectionFactory[]{ssl, alpn, spdy, http});
server.start();
我将其跟踪为https://bugs.eclipse.org/bugs/show_bug.cgi?id=440756。
最后,如果你不直接使用代码,但是使用Jetty作为服务器并将webapps部署到它,Jetty已经正确配置了ALPN或NPN,具体取决于激活的模块。