Troubleshooting the Event Hub
Jetty ALPN/NPN General Configuration Errors
If you are using a Java application to access the Event Hub service, you may receive the following error: java.lang.IllegalArgumentException: Jetty ALPN/NPN has not been properly configured
or java.lang.IllegalArgumentException: ALPN is not configured properly
.
Cause
There are several possible causes for the error message:
- Event Hub uses ALPN to integrate with SSL. The Java application's pom.xml file must define the appropriate dependences so that the JDK runtime is able to load the SSL library runtime provided by the dependency.
- Your instance of Springboot/Tomcat is not properly configured.
- You are using the wrong version of Google Guava or Guava is not configured.
- The application is using a conflicting version of
netty-tcnative-boringssl-static
as a dependency. - You are using an older version of
spring-boot-starter-parent
as a dependency.
Solutions
- Configure SSL so your Java application can integrate with Event Hub. To do this, add the following dependency as the first dependency to your Java application's pom.xml file:
<dependency> <groupId>io.netty</groupId> <artifactId>netty-tcnative-boringssl-static</artifactId> <version>1.1.33.Fork23</version> </dependency>
- Where possible, use Jetty as a container instead of Tomcat.
dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jetty</artifactId> </dependency>
- Verify that the application uses the Google Guava Library v18 or later.
- Remove the conflicting
netty-tcnative-boringssl-static
dependency from the end application. Use version that is already included as part of the Event Hub Java SDK jar file. - Upgrade version of
spring-boot-starter-parent
dependency to version 2.0.3.RELEASE with Java SDK v2.0.7.
Jetty ALPN/NPN Netty Configuration
If you are using a Java application to access the Event Hub service, you may receive the following error: java.lang.IllegalArgumentException: Jetty ALPN/NPN has not been properly configured.
Another error under java.lang.IllegalArgumentException is:
Jetty ALPN/NPN has not been properly configured at io.grpc.netty.GrpcSslContexts.selectApplicationProtocolConfig(GrpcSslContexts.java
In this instance, you can force the class loader to load
netty-tcnative-boringssl-static
library ahead of the tomcat-core library
at runtime, by providing the following dependency in your application pom file:<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<scope>provided</scope>
</dependency>
Using the Event Hub with other Containers
Event Hub can be configured to work with other containers.
Using Event Hub with other Containers
The Event Hub can be configured to use the following containers.
- The Jetty container requires two additional dependencies to your POM file. Note that the version of
alpn-boot
differs based on the JDK version being used, as described at http://www.eclipse.org/jetty/documentation/current/alpn-chapter.html#plan-versions.<dependency> <groupId>org.mortbay.jetty.alpn</groupId> <artifactId>alpn-boot</artifactId> <version>8.1.9.v20160720</version> </dependency> <dependency> <groupId>org.eclipse.jetty.alpn</groupId> <artifactId>alpn-api</artifactId> <version>1.1.3.v20160715</version> </dependency>
- For the Embedded Tomcat container (embedded) refer to the solution described at http://netty.io/wiki/forked-tomcat-native.html. In addition, ensure that the
netty-tcnative-boringssl-static
dependency is loaded beforetomcat-em-core
coming from tomcat-starter, since the system is looking for the org.apache.jni.Library which is present in both repos. Add following to your POM:<project> <properties> //for linux add linux <os.detection.classifierWithLikes>mac</os.detection.classifierWithLikes> </properties> ... <dependencies> ... <dependency> <groupId>io.netty</groupId> <artifactId>netty-tcnative</artifactId> <version>1.1.33.Fork16</version> <classifier>${os.detected.classifier}</classifier> </dependency> ... </dependencies> ... <build> ... <extensions> <extension> <groupId>kr.motd.maven</group Id> <artifactId>os-maven-plugin</artifactId> <version>1.4.0.Final</version> </extension> </extensions> ... </build> ... </project>
Note: The native Tomcat container using a
war
file cannot be used due to a namespace
conflict between org.apache.jni
in both tomcat and netty-tcnative-boringsll-static
.