Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot invoke "org.eclipse.jetty.io.ManagedSelector.getTotalKeys()" because "selector" is null #9947

Closed
minduch opened this issue Jun 22, 2023 · 13 comments · Fixed by #9962
Closed
Labels
Bug For general bugs on Jetty side

Comments

@minduch
Copy link

minduch commented Jun 22, 2023

Jetty version
Jetty 12 beta2

Java version/vendor (use: java -version)
openjdk version "17.0.7" 2023-04-18
OpenJDK Runtime Environment Temurin-17.0.7+7 (build 17.0.7+7)
OpenJDK 64-Bit Server VM Temurin-17.0.7+7 (build 17.0.7+7, mixed mode, sharing)

OS type/version
Windows 11 - Microsoft Windows [Version 10.0.22631.1900]

Description
Do not report security issues here! See Jetty Security Reports.

How to reproduce?
Happens everytime we launch our server that embeds Jetty. Previous builds of Jetty 12 did not have this problem, or at least we didn't encounter it.

Also: could someone give me a hint of where to find binary builds of Jetty 12 beta(x), e.g. nightly builds (also perhaps with some kind of indication as to how tests passed or not).

The stack trace:

java.lang.NullPointerException: Cannot invoke "org.eclipse.jetty.io.ManagedSelector.getTotalKeys()" because "selector" is null
          	at org.eclipse.jetty.io.SelectorManager.getTotalKeys(SelectorManager.java:153)
          	at org.eclipse.jetty.io.SelectorManager.toString(SelectorManager.java:530)
          	at java.base/java.util.Formatter$FormatSpecifier.printString(Formatter.java:3147)
          	at java.base/java.util.Formatter$FormatSpecifier.print(Formatter.java:3025)
          	at java.base/java.util.Formatter.format(Formatter.java:2781)
          	at java.base/java.util.Formatter.format(Formatter.java:2717)
          	at java.base/java.lang.String.format(String.java:4155)
          	at org.eclipse.jetty.util.component.ContainerLifeCycle$Bean.toString(ContainerLifeCycle.java:791)
          	at com.iizix.Utilities.toString(Utilities.java:2569)
          	at com.iizix.Loggers.format(Loggers.java:606)
          	at com.iizix.Loggers.logInternalForced(Loggers.java:529)
          	at com.iizix.Loggers.logForced(Loggers.java:358)
          	at com.iizix.log.slf4j.LogLoggerImpl.debug(LogLoggerImpl.java:337)
          	at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:419)
          	at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:317)
          	at org.eclipse.jetty.quic.server.QuicServerConnector.<init>(QuicServerConnector.java:83)
          	at org.eclipse.jetty.http3.server.HTTP3ServerConnector.<init>(HTTP3ServerConnector.java:49)
          	at org.eclipse.jetty.http3.server.HTTP3ServerConnector.<init>(HTTP3ServerConnector.java:44)

For some reason, the selector variable is null during this initialization of the HTTP/3 connector.

@minduch minduch added the Bug For general bugs on Jetty side label Jun 22, 2023
@sbordet
Copy link
Contributor

sbordet commented Jun 23, 2023

@strogiyotec can you take a look at this?

@strogiyotec
Copy link
Contributor

I will thanks @minduch could you show me how do you create an embedded jetty instance please
Otherwise I will try to replicate myself

@sbordet
Copy link
Contributor

sbordet commented Jun 23, 2023

@strogiyotec please set up a server as described here:
https://www.eclipse.org/jetty/documentation/jetty-12/programming-guide/index.html#pg-server-http3-setup

Then you can connect with JMC (or a similar JMX console) and try to see if you can reproduce the issue.

@sbordet
Copy link
Contributor

sbordet commented Jun 23, 2023

Also, see if jetty-10.0.x has the same issue. If so, fix it in the jetty-10.0.x branch and we will merge forward.

@minduch
Copy link
Author

minduch commented Jun 24, 2023

The test case we have is pretty large, but it should be quite straightforward if you just add a HTTP3 connector to the server. Our log file with Jetty debug logging turned on (with additional output) shows:

[FINE]    24 Jun 2023  17:03:04.577  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  QueuedThreadPool[qtp1101413821]@41a63dbd{STOPPED,8<=0<=200,i=0,r=-1,t=-8220282ms,q=0}[NO_TRY] added {org.eclipse.jetty.util.thread.ThreadPoolBudget@7164a1d8,POJO}
[FINE]    24 Jun 2023  17:03:04.602  <system>  <oej.http.PreEncodedHttpField>  [iiziServer,10,main]  loaded 4 HttpFieldPreEncoders
[FINE]    24 Jun 2023  17:03:04.623  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  oejs.Server@1e2e314a{STOPPED}[12.0.0.beta2,sto=0] added {QueuedThreadPool[qtp1101413821]@41a63dbd{STOPPED,8<=0<=200,i=0,r=-1,t=-8220328ms,q=0}[NO_TRY],AUTO}
[FINE]    24 Jun 2023  17:03:04.624  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  oejs.Server@1e2e314a{STOPPED}[12.0.0.beta2,sto=0] added {oejut.ScheduledExecutorScheduler@22f8769b{STOPPED},AUTO}
[FINE]    24 Jun 2023  17:03:04.628  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  oejs.Server@1e2e314a{STOPPED}[12.0.0.beta2,sto=0] added {org.eclipse.jetty.io.ArrayByteBufferPool@7d4c8f9d{min=0,max=65536,buckets=16,heap=0/134217728,direct=0/134217728},POJO}
[FINE]    24 Jun 2023  17:03:04.629  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  oejs.Server@1e2e314a{STOPPED}[12.0.0.beta2,sto=0] added {org.eclipse.jetty.util.resource.FileSystemPool@6522aef3,UNMANAGED}
[FINE]    24 Jun 2023  17:03:04.636  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  HttpConnectionFactory@10c80197[HTTP/1.1] added {HttpConfiguration@7f984b19{32768/8192,8192/8192,https://:0,[]},POJO}
[FINE]    24 Jun 2023  17:03:04.643  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  HTTP2CServerConnectionFactory@15382199[h2c] added {HTTP2SessionContainer@39e62525[size=0],POJO}
[FINE]    24 Jun 2023  17:03:04.643  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  HTTP2CServerConnectionFactory@15382199[h2c] added {HttpConfiguration@7f984b19{32768/8192,8192/8192,https://:0,[]},POJO}
[FINE]    24 Jun 2023  17:03:04.643  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  WSServerConnector@60e13592{null, ()}{0.0.0.0:0} added {QueuedThreadPool[qtp1101413821]@41a63dbd{STOPPED,8<=0<=200,i=0,r=-1,t=-8220348ms,q=0}[NO_TRY],UNMANAGED}
[FINE]    24 Jun 2023  17:03:04.643  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  WSServerConnector@60e13592{null, ()}{0.0.0.0:0} added {oejut.ScheduledExecutorScheduler@22f8769b{STOPPED},UNMANAGED}
[FINE]    24 Jun 2023  17:03:04.643  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  WSServerConnector@60e13592{null, ()}{0.0.0.0:0} added {org.eclipse.jetty.io.ArrayByteBufferPool@7d4c8f9d{min=0,max=65536,buckets=16,heap=0/134217728,direct=0/134217728},UNMANAGED}
[FINE]    24 Jun 2023  17:03:04.643  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  WSServerConnector@60e13592{null, (http/1.1)}{0.0.0.0:0} added {HttpConnectionFactory@10c80197[HTTP/1.1],AUTO}
[FINE]    24 Jun 2023  17:03:04.644  <system>  <oejs.AbstractConnector>  [iiziServer,10,main]  WSServerConnector@60e13592{HTTP/1.1, (http/1.1)}{0.0.0.0:0} added HttpConnectionFactory@10c80197[HTTP/1.1]
[FINE]    24 Jun 2023  17:03:04.644  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  WSServerConnector@60e13592{HTTP/1.1, (http/1.1, h2c)}{0.0.0.0:0} added {HTTP2CServerConnectionFactory@15382199[h2c],AUTO}
[FINE]    24 Jun 2023  17:03:04.644  <system>  <oejs.AbstractConnector>  [iiziServer,10,main]  WSServerConnector@60e13592{HTTP/1.1, (http/1.1, h2c)}{0.0.0.0:0} added HTTP2CServerConnectionFactory@15382199[h2c]
[FINE]    24 Jun 2023  17:03:04.646  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  WSServerConnector@60e13592{HTTP/1.1, (http/1.1, h2c)}{0.0.0.0:0} added {SelectorManager@WSServerConnector@60e13592{HTTP/1.1, (http/1.1, h2c)}{0.0.0.0:0},MANAGED}
[FINE]    24 Jun 2023  17:03:04.646  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  oejs.Server@1e2e314a{STOPPED}[12.0.0.beta2,sto=0] added {WSServerConnector@60e13592{HTTP/1.1, (http/1.1, h2c)}{0.0.0.0:80},AUTO}
[FINE]    24 Jun 2023  17:03:04.646  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  HttpConnectionFactory@33e54f4[HTTP/1.1] added {HttpConfiguration@60ae22{32768/8192,8192/8192,https://:0,[]},POJO}
[FINE]    24 Jun 2023  17:03:04.646  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  HTTP2CServerConnectionFactory@66a82864[h2c] added {HTTP2SessionContainer@7e122dfc[size=0],POJO}
[FINE]    24 Jun 2023  17:03:04.646  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  HTTP2CServerConnectionFactory@66a82864[h2c] added {HttpConfiguration@60ae22{32768/8192,8192/8192,https://:0,[]},POJO}
[FINE]    24 Jun 2023  17:03:04.646  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  WSServerConnector@f7a5f3e{null, ()}{0.0.0.0:0} added {QueuedThreadPool[qtp1101413821]@41a63dbd{STOPPED,8<=0<=200,i=0,r=-1,t=-8220351ms,q=0}[NO_TRY],UNMANAGED}
[FINE]    24 Jun 2023  17:03:04.646  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  WSServerConnector@f7a5f3e{null, ()}{0.0.0.0:0} added {oejut.ScheduledExecutorScheduler@22f8769b{STOPPED},UNMANAGED}
[FINE]    24 Jun 2023  17:03:04.647  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  WSServerConnector@f7a5f3e{null, ()}{0.0.0.0:0} added {org.eclipse.jetty.io.ArrayByteBufferPool@7d4c8f9d{min=0,max=65536,buckets=16,heap=0/134217728,direct=0/134217728},UNMANAGED}
[FINE]    24 Jun 2023  17:03:04.647  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  WSServerConnector@f7a5f3e{null, (http/1.1)}{0.0.0.0:0} added {HttpConnectionFactory@33e54f4[HTTP/1.1],AUTO}
[FINE]    24 Jun 2023  17:03:04.647  <system>  <oejs.AbstractConnector>  [iiziServer,10,main]  WSServerConnector@f7a5f3e{HTTP/1.1, (http/1.1)}{0.0.0.0:0} added HttpConnectionFactory@33e54f4[HTTP/1.1]
[FINE]    24 Jun 2023  17:03:04.647  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  WSServerConnector@f7a5f3e{HTTP/1.1, (http/1.1, h2c)}{0.0.0.0:0} added {HTTP2CServerConnectionFactory@66a82864[h2c],AUTO}
[FINE]    24 Jun 2023  17:03:04.647  <system>  <oejs.AbstractConnector>  [iiziServer,10,main]  WSServerConnector@f7a5f3e{HTTP/1.1, (http/1.1, h2c)}{0.0.0.0:0} added HTTP2CServerConnectionFactory@66a82864[h2c]
[FINE]    24 Jun 2023  17:03:04.647  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  WSServerConnector@f7a5f3e{HTTP/1.1, (http/1.1, h2c)}{0.0.0.0:0} added {SelectorManager@WSServerConnector@f7a5f3e{HTTP/1.1, (http/1.1, h2c)}{0.0.0.0:0},MANAGED}
[FINE]    24 Jun 2023  17:03:04.647  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  oejs.Server@1e2e314a{STOPPED}[12.0.0.beta2,sto=0] added {WSServerConnector@f7a5f3e{HTTP/1.1, (http/1.1, h2c)}{0.0.0.0:8080},AUTO}
[FINE]    24 Jun 2023  17:03:04.683  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  HttpConnectionFactory@2814800[HTTP/1.1] added {HttpConfiguration@6f2c59fa{32768/8192,8192/8192,https://:0,[SecureRequestCustomizer@6f98ed00]},POJO}
[FINE]    24 Jun 2023  17:03:04.683  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  HTTP2ServerConnectionFactory@41205664[h2] added {HTTP2SessionContainer@4969d708[size=0],POJO}
[FINE]    24 Jun 2023  17:03:04.683  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  HTTP2ServerConnectionFactory@41205664[h2] added {HttpConfiguration@6f2c59fa{32768/8192,8192/8192,https://:0,[SecureRequestCustomizer@6f98ed00]},POJO}
[FINE]    24 Jun 2023  17:03:04.690  <system>  <oej.alpn.conscrypt.server.ConscryptServerALPNProcessor>  [iiziServer,10,main]  Added Conscrypt provider
[FINE]    24 Jun 2023  17:03:04.691  <system>  <oej.alpn.server.ALPNServerConnectionFactory>  [iiziServer,10,main]  protocols: []
[FINE]    24 Jun 2023  17:03:04.691  <system>  <oej.alpn.server.ALPNServerConnectionFactory>  [iiziServer,10,main]  processors: [org.eclipse.jetty.alpn.conscrypt.server.ConscryptServerALPNProcessor@3f362d33, org.eclipse.jetty.alpn.java.server.JDK9ServerALPNProcessor@6050f26e]
[FINE]    24 Jun 2023  17:03:04.693  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  SslConnectionFactory@53312d76{SSL->alpn} added {Server@1c6a1402[provider=Conscrypt,keyStore=null,trustStore=null],AUTO}
[FINE]    24 Jun 2023  17:03:04.693  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  WSServerConnector@6f6a090f{null, ()}{0.0.0.0:0} added {QueuedThreadPool[qtp1101413821]@41a63dbd{STOPPED,8<=0<=200,i=0,r=-1,t=-8220397ms,q=0}[NO_TRY],UNMANAGED}
[FINE]    24 Jun 2023  17:03:04.693  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  WSServerConnector@6f6a090f{null, ()}{0.0.0.0:0} added {oejut.ScheduledExecutorScheduler@22f8769b{STOPPED},UNMANAGED}
[FINE]    24 Jun 2023  17:03:04.693  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  WSServerConnector@6f6a090f{null, ()}{0.0.0.0:0} added {org.eclipse.jetty.io.ArrayByteBufferPool@7d4c8f9d{min=0,max=65536,buckets=16,heap=0/134217728,direct=0/134217728},UNMANAGED}
[FINE]    24 Jun 2023  17:03:04.693  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  WSServerConnector@6f6a090f{null, (ssl)}{0.0.0.0:0} added {SslConnectionFactory@53312d76{SSL->alpn},AUTO}
[FINE]    24 Jun 2023  17:03:04.693  <system>  <oejs.AbstractConnector>  [iiziServer,10,main]  WSServerConnector@6f6a090f{SSL, (ssl)}{0.0.0.0:0} added SslConnectionFactory@53312d76{SSL->alpn}
[FINE]    24 Jun 2023  17:03:04.693  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  WSServerConnector@6f6a090f{SSL, (ssl, alpn)}{0.0.0.0:0} added {ALPNServerConnectionFactory@383942e3{[alpn],HTTP/1.1,[]},AUTO}
[FINE]    24 Jun 2023  17:03:04.693  <system>  <oejs.AbstractConnector>  [iiziServer,10,main]  WSServerConnector@6f6a090f{SSL, (ssl, alpn)}{0.0.0.0:0} added ALPNServerConnectionFactory@383942e3{[alpn],HTTP/1.1,[]}
[FINE]    24 Jun 2023  17:03:04.693  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  WSServerConnector@6f6a090f{SSL, (ssl, alpn, h2)}{0.0.0.0:0} added {HTTP2ServerConnectionFactory@41205664[h2],AUTO}
[FINE]    24 Jun 2023  17:03:04.693  <system>  <oejs.AbstractConnector>  [iiziServer,10,main]  WSServerConnector@6f6a090f{SSL, (ssl, alpn, h2)}{0.0.0.0:0} added HTTP2ServerConnectionFactory@41205664[h2]
[FINE]    24 Jun 2023  17:03:04.694  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  WSServerConnector@6f6a090f{SSL, (ssl, alpn, h2, http/1.1)}{0.0.0.0:0} added {HttpConnectionFactory@2814800[HTTP/1.1],AUTO}
[FINE]    24 Jun 2023  17:03:04.694  <system>  <oejs.AbstractConnector>  [iiziServer,10,main]  WSServerConnector@6f6a090f{SSL, (ssl, alpn, h2, http/1.1)}{0.0.0.0:0} added HttpConnectionFactory@2814800[HTTP/1.1]
[FINE]    24 Jun 2023  17:03:04.694  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  WSServerConnector@6f6a090f{SSL, (ssl, alpn, h2, http/1.1)}{0.0.0.0:0} added {SelectorManager@WSServerConnector@6f6a090f{SSL, (ssl, alpn, h2, http/1.1)}{0.0.0.0:0},MANAGED}
[FINE]    24 Jun 2023  17:03:04.698  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  HTTP3ServerConnectionFactory@2154adb0[h3] added {org.eclipse.jetty.http3.HTTP3Configuration@5a5fbb49,POJO}
[FINE]    24 Jun 2023  17:03:04.699  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  HTTP3ServerConnectionFactory@2154adb0[h3] added {HttpConfiguration@6f2c59fa{32768/8192,8192/8192,https://:0,[SecureRequestCustomizer@6f98ed00]},POJO}
[FINE]    24 Jun 2023  17:03:04.700  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  WSServerConnector3@2974dd73{null, ()}{0.0.0.0:0} added {QueuedThreadPool[qtp1101413821]@41a63dbd{STOPPED,8<=0<=200,i=0,r=-1,t=-8220405ms,q=0}[NO_TRY],UNMANAGED}
[FINE]    24 Jun 2023  17:03:04.700  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  WSServerConnector3@2974dd73{null, ()}{0.0.0.0:0} added {oejut.ScheduledExecutorScheduler@22f8769b{STOPPED},UNMANAGED}
[FINE]    24 Jun 2023  17:03:04.700  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  WSServerConnector3@2974dd73{null, ()}{0.0.0.0:0} added {org.eclipse.jetty.io.ArrayByteBufferPool@7d4c8f9d{min=0,max=65536,buckets=16,heap=0/134217728,direct=0/134217728},UNMANAGED}
[FINE]    24 Jun 2023  17:03:04.700  <system>  <oeju.component.ContainerLifeCycle>  [iiziServer,10,main]  WSServerConnector3@2974dd73{null, (h3)}{0.0.0.0:0} added {HTTP3ServerConnectionFactory@2154adb0[h3],AUTO}
[FINE]    24 Jun 2023  17:03:04.701  <system>  <oejs.AbstractConnector>  [iiziServer,10,main]  WSServerConnector3@2974dd73{h3, (h3)}{0.0.0.0:0} added HTTP3ServerConnectionFactory@2154adb0[h3]
[SEVERE]  24 Jun 2023  17:03:04.703  <system>  <cis.ServerShell>  [main,5,main]  Failed creation of Server Worker: [java.lang.NullPointerException: Cannot invoke "org.eclipse.jetty.io.ManagedSelector.getTotalKeys()" because "selector" is null
          	at org.eclipse.jetty.io.SelectorManager.getTotalKeys(SelectorManager.java:153)
          	at org.eclipse.jetty.io.SelectorManager.toString(SelectorManager.java:530)
          	at java.base/java.util.Formatter$FormatSpecifier.printString(Formatter.java:3056)
          	at java.base/java.util.Formatter$FormatSpecifier.print(Formatter.java:2933)
          	at java.base/java.util.Formatter.format(Formatter.java:2689)
          	at java.base/java.util.Formatter.format(Formatter.java:2625)
          	at java.base/java.lang.String.format(String.java:4141)
          	at org.eclipse.jetty.util.component.ContainerLifeCycle$Bean.toString(ContainerLifeCycle.java:791)
          	at com.iizix.Utilities.toString(Utilities.java:2586)
          	at com.iizix.Loggers.format(Loggers.java:606)
          	at com.iizix.Loggers.logInternalForced(Loggers.java:529)
          	at com.iizix.Loggers.logForced(Loggers.java:358)
          	at com.iizix.log.slf4j.LogLoggerImpl.debug(LogLoggerImpl.java:337)
          	at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:419)
          	at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:317)
          	at org.eclipse.jetty.quic.server.QuicServerConnector.<init>(QuicServerConnector.java:83)
          	at org.eclipse.jetty.http3.server.HTTP3ServerConnector.<init>(HTTP3ServerConnector.java:49)
          	at org.eclipse.jetty.http3.server.HTTP3ServerConnector.<init>(HTTP3ServerConnector.java:44)
          	at com.iizix.jetty.WSServerConnector3.<init>(WSServerConnector3.java:79)
          	at com.iizix.jetty.WSHelper.createHttpsConnector(WSHelper.java:843)
          	at com.iizix.jetty.WSHelper.createWebServer(WSHelper.java:660)
          	at com.iizix.jetty.RunConfigurationWebServer.startWebServer(RunConfigurationWebServer.java:271)
          	at com.iizix.server.JettyRunConfiguration.onStartServer(JettyRunConfiguration.java:720)
          	at com.iizix.server.ServerShell.onWorkerStarted(ServerShell.java:438)
          	at com.iizix.server.ServerShell.lambda$2(ServerShell.java:862)
          	at java.base/java.lang.Thread.run(Thread.java:833)
          ]
[SEVERE]  24 Jun 2023  17:03:04.703  <system>  <cis.StandardServer>  [main,5,main]  Failed starting server: [java.lang.NullPointerException: Cannot invoke "org.eclipse.jetty.io.ManagedSelector.getTotalKeys()" because "selector" is null
          	at org.eclipse.jetty.io.SelectorManager.getTotalKeys(SelectorManager.java:153)
          	at org.eclipse.jetty.io.SelectorManager.toString(SelectorManager.java:530)
          	at java.base/java.util.Formatter$FormatSpecifier.printString(Formatter.java:3056)
          	at java.base/java.util.Formatter$FormatSpecifier.print(Formatter.java:2933)
          	at java.base/java.util.Formatter.format(Formatter.java:2689)
          	at java.base/java.util.Formatter.format(Formatter.java:2625)
          	at java.base/java.lang.String.format(String.java:4141)
          	at org.eclipse.jetty.util.component.ContainerLifeCycle$Bean.toString(ContainerLifeCycle.java:791)
          	at com.iizix.Utilities.toString(Utilities.java:2586)
          	at com.iizix.Loggers.format(Loggers.java:606)
          	at com.iizix.Loggers.logInternalForced(Loggers.java:529)
          	at com.iizix.Loggers.logForced(Loggers.java:358)
          	at com.iizix.log.slf4j.LogLoggerImpl.debug(LogLoggerImpl.java:337)
          	at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:419)
          	at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:317)
          	at org.eclipse.jetty.quic.server.QuicServerConnector.<init>(QuicServerConnector.java:83)
          	at org.eclipse.jetty.http3.server.HTTP3ServerConnector.<init>(HTTP3ServerConnector.java:49)
          	at org.eclipse.jetty.http3.server.HTTP3ServerConnector.<init>(HTTP3ServerConnector.java:44)
          	at com.iizix.jetty.WSServerConnector3.<init>(WSServerConnector3.java:79)
          	at com.iizix.jetty.WSHelper.createHttpsConnector(WSHelper.java:843)
          	at com.iizix.jetty.WSHelper.createWebServer(WSHelper.java:660)
          	at com.iizix.jetty.RunConfigurationWebServer.startWebServer(RunConfigurationWebServer.java:271)
          	at com.iizix.server.JettyRunConfiguration.onStartServer(JettyRunConfiguration.java:720)
          	at com.iizix.server.ServerShell.onWorkerStarted(ServerShell.java:438)
          	at com.iizix.server.ServerShell.lambda$2(ServerShell.java:862)
          	at java.base/java.lang.Thread.run(Thread.java:833)
          ]

Basically our HTTPS connector(s) are created using the following code, where the flags useHTTP2, useHTTP3 along with useConscrypt are booleans in another piece of code:

    SslContextFactory.Server sslContextFactory=new SslContextFactory.Server();
    sslContextFactory.setTrustAll(true);
    sslContextFactory.setKeyStore(keyStore);
    sslContextFactory.setKeyStorePassword(pw);
    sslContextFactory.addExcludeProtocols("TLSv1","TLSv1.1");
    sslContextFactory.setRenegotiationAllowed(false);
    sslContextFactory.setCipherComparator(HTTP2Cipher.COMPARATOR);
    sslContextFactory.setUseCipherSuitesOrder(true);
    
    // Use Conscrypt?
    if ( useConscrypt )
      sslContextFactory.setProvider("Conscrypt");
    
    // SNI host check is 'false'!
    HttpConfiguration https_config=new HttpConfiguration();
    SecureRequestCustomizer src=new SecureRequestCustomizer(false);
    https_config.addCustomizer(src);
    
    HttpConnectionFactory http=new HttpConnectionFactory(https_config);

    ServerConnector httpsConnector;
    String http11=http.getProtocol();
    
    if ( useHTTP2 )
      {
      // HTTP/2 Connection Factories: h2 = HTTP/2, needs ALPN.
      HTTP2ServerConnectionFactory h2=new HTTP2ServerConnectionFactory(https_config);
      ALPNServerConnectionFactory alpn=new ALPNServerConnectionFactory();
      alpn.setDefaultProtocol(http11);
      String alpnProtocol=alpn.getProtocol();
      SslConnectionFactory tls=new SslConnectionFactory(sslContextFactory,alpnProtocol);
      httpsConnector=new ServerConnector(server,tls,alpn,h2,http);
      
      if ( useHTTP3 )
        {
        // Create the HTTP/3 UDP connector on the selected port "http3Port" (443 for example).
        @SuppressWarnings("resource")
        HTTP3ServerConnector https3Connector=new HTTP3ServerConnector(server,sslContextFactory,new HTTP3ServerConnectionFactory(https_config));
        https3Connector.setPort(http3Port);
        
        // Set bind address if any.
        if ( bind!=null )
          https3Connector.setHost(bind);
        
        server.addConnector(https3Connector);
        }
      }
    else
      {
      // Just plain HTTP/1.x using TLS, no ALPN is required...
      SslConnectionFactory tls=new SslConnectionFactory(sslContextFactory,http11);
      httpsConnector=new ServerConnector(server,tls,http);
      }
 
    // Set port (443 for example).
    httpsConnector.setPort(port);
    
    // Set bind address if any.
    if ( bind!=null )
      httpsConnector.setHost(bind);

Let me know if you need more pieces of code. If you look carefully in the log output, you will see WSServerConnector and WSServerConnector3, these are subclasses of ServerConnector and HTTP3ServerConnector respectively that we require, and I don't think you need this in the test case.

@strogiyotec
Copy link
Contributor

strogiyotec commented Jun 24, 2023

@minduch thanks for the code sample I tried to reproduce it on my end but didn't trigger the error
Could you take a look at this gist
My dependencies are

 <dependency>
            <groupId>org.eclipse.jetty.http3</groupId>
            <artifactId>jetty-http3-server</artifactId>
            <version>12.0.0.beta2</version>
        </dependency>


        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-jmx</artifactId>
            <version>12.0.0.beta2</version>
        </dependency>

Just in case the error you encountered means that jetty can't expose the metric over JMX
this metric is

  @ManagedAttribute(value = "Total number of keys in all selectors", readonly = true)
    public int getTotalKeys()
    {
        int keys = 0;
        for (final ManagedSelector selector : _selectors)
        {
            keys += selector.getTotalKeys();
        }
        return keys;
    }

The _selectors array can't be empty, could you take a look if your connect was configured according to the docs ?
https://www.eclipse.org/jetty/documentation/jetty-12/programming-guide/index.html#pg-server-http3-setup

@sbordet
Copy link
Contributor

sbordet commented Jun 24, 2023

@strogiyotec I think getTotalKeys() is called during startup, before the _selectors array is populated.

There should be a null check for variable selector in the loop.

If you want to contribute a PR, please do this work in branch jetty-10.0.x and we will merge forward.
Thanks!

@strogiyotec
Copy link
Contributor

Will do shortly

strogiyotec added a commit to strogiyotec/jetty.project that referenced this issue Jun 24, 2023
@strogiyotec
Copy link
Contributor

@sbordet PR is ready
#9962

strogiyotec added a commit to strogiyotec/jetty.project that referenced this issue Jun 24, 2023
strogiyotec added a commit to strogiyotec/jetty.project that referenced this issue Jun 24, 2023
@sbordet
Copy link
Contributor

sbordet commented Jun 25, 2023

@minduch would be great if you could confirm this issue is fixed for you.

You can find nightly builds at https://oss.sonatype.org/content/repositories/jetty-snapshots/.

@strogiyotec thanks for the fix!

@minduch
Copy link
Author

minduch commented Jun 27, 2023

@sbordet Is there an easy way to download the latest SNAPSHOT Jars? Our Maven based test case works for some reason with beta2 right now, but our “real product” does not. And to add the nightly build into the product, I need to download most of the Jetty Jars manually, which is very tedious. Is there a ZIP file that contains all of Jetty, much like the one of beta0 (that has not been updated to beta1 or beta2) at Jetty Downloads - The Eclipse Foundation (https://www.eclipse.org/jetty/download.php)? Any idea when beta3 will come out?

@sbordet
Copy link
Contributor

sbordet commented Jun 27, 2023

You can download the latest jar from here: https://oss.sonatype.org/content/repositories/jetty-snapshots/org/eclipse/jetty/jetty-io/12.0.0-SNAPSHOT/

Rename it to jetty-io-12.0.0.beta2, replace the original and you should be good.

12.0.0.beta3 will come out in a few days.

@minduch
Copy link
Author

minduch commented Jul 25, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
3 participants