I have such code:
public static void main(String[] args) throws Exception {
System.out.println("ALPN class: " + ALPN.class);
HelloWorldClient client = new HelloWorldClient("localhost", 10009);
}
This gives such output:
ALPN class: class org.eclipse.jetty.alpn.ALPN
Exception in thread "main" java.lang.IllegalArgumentException: ALPN is not configured properly. See https://github.com/grpc/grpc-java/blob/master/SECURITY.md#troubleshooting for more information.
at io.grpc.netty.GrpcSslContexts.selectApplicationProtocolConfig(GrpcSslContexts.java:163)
at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:136)
at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:124)
at io.grpc.netty.GrpcSslContexts.forClient(GrpcSslContexts.java:94)
at btcduke.node.ln.HelloWorldClient.<init>(HelloWorldClient.java:35)
at btcduke.node.ln.HelloWorldClient.main(HelloWorldClient.java:76)
Caused by: java.lang.ClassNotFoundException: org/eclipse/jetty/alpn/ALPN
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at io.grpc.netty.JettyTlsUtil.isJettyAlpnConfigured(JettyTlsUtil.java:34)
at io.grpc.netty.GrpcSslContexts.selectApplicationProtocolConfig(GrpcSslContexts.java:153)
... 5 more
HelloWorldClient uses grpc, and it looks grpc is trying to load ALPN class dynamically. Am I right? This class can't be find, so I have error message. But please take a look,that I have access to this class (I print this class in first line). Do anyone knows why it happens this way? I have no idea :/
I toretically solved this issue by adding VM argument "-Xbootclasspath/p:" to run configuration option, but I don't understand why I needed to do this and also I don't think this is elegant method.
Documented at https://www.eclipse.org/jetty/documentation/jetty-9/index.php#alpn-chapter
For Java 8 up to 1.8.0_242 included.
You MUST use the alpn-boot
provider for your specific JVM, as it modifies OpenJDK classes to enable support for ALPN.
See ALPN to OpenJDK version list:
https://www.eclipse.org/jetty/documentation/jetty-9/index.html#alpn-versions
This alpn-boot-<ver>.jar
requires use of the -Xbootclasspath/p:
option on the JVM command line.
You will also use the jetty-alpn-openjdk8-server-<ver>.jar
on your normal Server classpath for your specific version of Jetty server.
For Java 8 from 1.8.0_252 and later (including Java 9+).
For Java 8 from 1.8.0_252 included and later, this provider uses the standard OpenJDK ALPN APIs introduced in Java 9 (see below) that have been backported to 1.8.0_252 and does not require the -Xbootclasspath/p:
option on command line
For this operational mode, use the jetty-alpn-java-server-<ver>.jar
artifact on your server classpath.
If you received an error message "ALPN is not configured properly" or "Jetty ALPN/NPN has not been properly configured", it most likely means that:
ALPN related dependencies are either not present in the classpath or that there is a classpath conflict or that a wrong version is used due to dependency management.
Looking closely at the provided stacktrace, it reveals that you need to configure "ALPN" properly
Caused by: java.lang.ClassNotFoundException:
org/eclipse/jetty/alpn/ALPN
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at
io.grpc.netty.JettyTlsUtil.isJettyAlpnConfigured(JettyTlsUtil.java:34)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.