3

I went thru this page: https://www.eclipse.org/jetty/documentation/9.3.x/alpn-chapter.html to have an ALPN boot jar in my classpath and still I can't get it working.

I am confused as to know if I need an Open SDK Java 8 than Oracle Java 8.

My Java version is:

java -version
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)

And I'm using the following versions of Jetty and ALPN boot:

<jetty-version>9.4.0.M1</jetty-version>
<alpn-version>8.1.9.v20160720</alpn-version>    
<dependency>
        <groupId>org.mortbay.jetty.alpn</groupId>
        <artifactId>alpn-boot</artifactId>
        <version>${alpn-version}</version>
</dependency>
<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-client</artifactId>
    <version>${jetty-version}</version>
</dependency>
<dependency>
    <groupId>org.eclipse.jetty.http2</groupId>
    <artifactId>http2-client</artifactId>
    <version>${jetty-version}</version>
</dependency>
<dependency>
    <groupId>org.eclipse.jetty.http2</groupId>
    <artifactId>http2-http-client-transport</artifactId>
    <version>${jetty-version}</version>
</dependency>
<dependency>
    <groupId>org.eclipse.jetty.http2</groupId>
    <artifactId>http2-common</artifactId>
    <version>${jetty-version}</version>
</dependency>
<dependency>
    <groupId>org.eclipse.jetty.http2</groupId>
    <artifactId>http2-hpack</artifactId>
    <version>${jetty-version}</version>
</dependency>

Also I tried using different versions of Jetty and ALPN which I found here https://mvnrepository.com/artifact/org.mortbay.jetty.alpn/alpn-boot and here https://mvnrepository.com/search?q=org.eclipse.jetty

Whichever ways I tried I never got it working submitting a POST request to an HTTP/2 endpoint.

However with Netty and the following dependency my tests were successful:

<dependency>
           <groupId>io.netty</groupId>
           <artifactId>netty-tcnative-boringssl-static</artifactId>
           <version>1.1.33.Fork22</version>
       </dependency>

Where do I find the documentation to see which version of ALPN boot is compatible with Oracle JDK? Is ALPN boot only compatible with OpenJDK?

I read that starting Java 9 support for ALPN will be native.

On a side note, which one is better? Netty or Jetty for HTTP/2 calls.

serverfaces
  • 1,155
  • 4
  • 22
  • 49
  • The [ALPN versions table](https://www.eclipse.org/jetty/documentation/current/alpn-chapter.html#alpn-versions) has the list of alpn-boot versions to java versions you are seeking – Joakim Erdfelt Oct 04 '16 at 18:08

2 Answers2

4

Netty is preferred for several reasons for making Http/2 connections. Few advantages I have seen using it are :

  • No need for the ALPN jar to be added to the boot classpath. Adding maven dependency "netty-tcnative-boringssl-static" does the job
  • It inherently support a asynchronous model of using the API. Hence it makes it simpler to handle data pushed by the server in case of HTTP/2
Neeraj Krishna
  • 1,527
  • 2
  • 16
  • 22
3

Jetty's ALPN boot jar works with both OpenJDK and Oracle's JDK (which is based on OpenJDK).

Jetty's ALPN boot jar must be in the boot classpath, not the regular classpath, like the documentation you linked says.

As such, you must not declare it as a dependency in your pom.xml files (there is no need to, like there is no need for you to specify a dependency on the JDK classes).

JDK 9 will have ALPN support native, there is already some work in that direction.

sbordet
  • 16,856
  • 1
  • 50
  • 45
  • Thanks, I tried setting it this way too: -Xbootclasspath/p:/Users/foo/.m2/repository/org/mortbay/jetty/alpn/alpn-boot/8.1.5.v20150921/alpn-boot-8.1.5.v20150921.jar – serverfaces Oct 04 '16 at 18:41
  • 2
    You are on JDK 8u11 (very old, please update), so you must use ALPN boot jar version 8.1.0.v20141016. You want to refer to [this table](https://www.eclipse.org/jetty/documentation/current/alpn-chapter.html#alpn-versions) for the right match of JDK and ALPN. – sbordet Oct 05 '16 at 07:01
  • What is needed for 9.4.x to work with Java 9? Are there any docs published? – nilskp Dec 02 '17 at 19:02