Exception when configuring SSL: "Jetty ALPN/NPN has not been properly configured." (and possible solution)
See original GitHub issueI am unable to configure an SSL gRPC.
SslContextBuilder sslBuilder = GrpcSslContexts.forServer(new File("a"), new File("b"))
sslBuilder.build();
Causes this exception:
Exception in thread "main" java.lang.IllegalArgumentException: Jetty ALPN/NPN has not been properly configured.
at io.grpc.netty.GrpcSslContexts.selectApplicationProtocolConfig(GrpcSslContexts.java:143)
at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:120)
at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:109)
at io.grpc.netty.GrpcSslContexts.forServer(GrpcSslContexts.java:90)
I think the root cause is here:
/**
* Indicates whether or not the Jetty ALPN jar is installed in the boot classloader.
*/
static boolean isJettyAlpnConfigured() {
try {
Class.forName("org.eclipse.jetty.alpn.ALPN", true, null);
return true;
} catch (ClassNotFoundException e) {
return false;
}
}
This method is restricting the search to the boot classloader, which I don’t think is correct. i.e. in the following code, the first line executes fine, but the second line throws CNFE (despite the class being loaded), causing isJettyAlpnConfigured()
to return false:
System.out.println("Class loaded? " + org.eclipse.jetty.alpn.ALPN.class);
System.out.println("Maybe not: " + Class.forName("org.eclipse.jetty.alpn.ALPN", true, null));
I suspect the Class.forName(String)
variant should be used instead (which doesn’t throw CNFE), but maybe there was some good rationale for restricting to the boot classpath?
FWIW I am using alpn-api-1.1.2.v20150522.jar with the following other deps: grpc-all-0.9.0.jar hpack-0.10.1.jar netty-all-4.1.0.Beta6.jar okhttp-2.4.0.jar okio-1.6.0.jar protobuf-java-3.0.0-beta-1.jar
Issue Analytics
- State:
- Created 8 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Jetty ALPN/NPN has not been properly configured - Stack ...
This solution might help some who is using spring boot application with embedded jetty server. Following should be the entries in pom.xml file....
Read more >Jetty ALPN/NPN has not been properly configured.
Jetty ALPN/NPN has not been properly configured. Here is the traceback. java.lang.IllegalArgumentException: Could not instantiate implementation: ...
Read more >Jetty ALPN/NPN has not been properly configured — Solution
In order to fix this, we need to configure an ALPN client that matches our JDK version for our project.
Read more >Authentication
ALPN is a fairly new standard and (where possible) gRPC also supports ... or “Jetty ALPN/NPN has not been properly configured”, it most...
Read more >Jetty ALPN/NPN has not been properly configured-Springboot
[Solved]-java.lang.IllegalArgumentException: Jetty ALPN/NPN has not been properly configured-Springboot ... Try adding a runtime dependency on netty-tcnative- ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is my way:
/usr/local/Cellar/tomcat/8.5.3/libexec/bin/catalina.sh
CATALINA_OPTS="-javaagent:/Library/Tomcat/lib/jetty-alpn-agent-2.0.6.jar"
../bin/shutdown.sh ../bin/startup.sh
For non-tomcat app, I could make it work with
-javaagent
on CentOS; which is documented in https://github.com/grpc/grpc-java/blob/master/SECURITY.md#tls-with-jdk-jetty-alpnnpn. BUT For some reason does not requirejetty-alpn
on MacOS.