Getting java.lang.IllegalArgumentException: Jetty ALPN/NPN has not been properly configured
, while using gRPC(google pub/sub)
to publish/consumes messages from Kafka.

- 5,179
- 10
- 35
- 56

- 357
- 4
- 8
-
Please provide [mcve]. – zett42 Mar 26 '17 at 19:18
-
formatting and new tag – HRgiger Mar 26 '17 at 22:06
-
are you using spring boot w/ embedded tomcat? – saturnism Apr 07 '17 at 22:38
-
Yes, we use spring boot with embedded tomcat – Yoga Gowda Apr 17 '17 at 04:38
5 Answers
Try adding a runtime dependency on netty-tcnative-boringssl-static. See gRPC's SECURITY.md. Note that the version of netty-tcnative necessary changes over time; you should look at the version of the document for a particular release (e.g., this is for 1.2.0).

- 24,057
- 5
- 55
- 76
- As suggested by google, use jetty container instead of tomcat, this solution works, but in our production, applications deployed on tomcat container, but of course I need it to work on tomcat in production.
- On debugging the gRPC code, found that guava version causing the issue, updated the guava version 18.0, (where in some classes missed in previous versions), solved the problem , but failed while deploying in CF
- Customized emebed-tomcat-core, and it works fine consistently, but again, team say no to custom tomcat container.
Java –jar apm-asset-xxxx.jar
– works fine locally, but need to provide a custom command to CF start, didn’t have luxury to change the CF start process.Finally, trick, the class loader to use tcnative-boring-ssl, library instead of tomcat-core library at runtime, by providing the following dependency in pom.xml. For the past 3 days, this solution is working CF.
org.springframework.boot spring-boot-starter-web org.hibernate * org.apache.tomcat.embed tomcat-embed-core org.apache.tomcat.embed tomcat-embed-core provided
Maven manifest plugin to promote the tc-native library to the top in the classloader.

- 5,215
- 5
- 51
- 90

- 357
- 4
- 8
Finally, went back to boot class class path approach. Prefixed the jetty-alpn.jar to boot class path and it starts working fine in cloud foundry now.

- 357
- 4
- 8
Adding the ALPN client JAR which matches my JDK version fixed this issue for me. In eclipse, you need to set up the jar as a bootstrap entry for the tomcat server.
You can find more info about it here : https://medium.com/@Parithi/jetty-alpn-npn-has-not-been-properly-configured-solution-418417ee6502

- 377
- 1
- 11
In POM, try to place the gRPC dependency before the spring boot dependency (the order of dependencies matters). I did that and the issue was solved. For example:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-language</artifactId>
<version>0.13.0-beta</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

- 49
- 1
- 6
-
The order of dependencies doesn't matter, it works in local, having gRPC/tc-native being before spring-boot. When you deployed in Cloud Foundry, the dependent jar extracted to app folder in the order of alpha numeric. – Yoga Gowda Apr 20 '17 at 16:05
-
I see, then the issue may be different from mine. I was trying on Google Cloud... – Lu Fangjian May 04 '17 at 15:34