-
Bug
-
Resolution: Unresolved
-
Minor
-
Jenkins 2.162
-
Powered by SuggestiMate -
Jenkins 2.185
Hi oleg_nenashev
I'm using Jenkins version 2.162
When I restart jenkins using /restart command or after plugin installation I got the following error at Jenkins restart page:
Stack tracejava.lang.IllegalStateException: Expected 1 instance of hudson.model.User$AllUsers but got 0 at hudson.ExtensionList.lookupSingleton(ExtensionList.java:450) at hudson.model.User$AllUsers.getInstance(User.java:1084) at hudson.model.User$AllUsers.get(User.java:1102) at hudson.model.User$AllUsers.access$100(User.java:1065) at hudson.model.User.getOrCreateById(User.java:521) at hudson.model.User.getById(User.java:619) at hudson.security.HttpSessionContextIntegrationFilter2.hasInvalidSessionSeed(HttpSessionContextIntegrationFilter2.java:87) at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:60) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:90) at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642) at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642) at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642) at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595) at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1340) at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564) at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1242) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) at org.eclipse.jetty.server.Server.handle(Server.java:503) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:364) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260) at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305) at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126) at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765) at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683) at java.lang.Thread.run(Thread.java:748)
As I see frontend part scripts/loading.js:53 sent GET request to server URL and got 500 code.
The normal behaviour of loading.js:41 should get 503 code from the server
[JENKINS-55945] Got IllegalStateException while restart Jenkins
I got this when I loaded a locally compiled version of the Stash pull request builder plugin and selected the "Restart Jenkins" checkbox. I saw that message. I reloaded the page after a few seconds, Jenkins is working normally. Jenkins 2.164 in Docker.
Getting this when restarting after updating a plugin. Clicking the checkbox for restarting jenkins when no jobs are running, will immediately produce this error.
However, if I wait for Jenkins to restart, it will eventually restart properly.
This is on a brand new Jenkins installation using the official docker image on an Ubuntu 18.04 EC2 instance.
Like urinalcake, I received this error when clicking the "Restart jenkins when no jobs are running" from the pluginManager/updatePlugins area.
I also encounter this in the same context as Boyd and Michael - a workaround for me was to log out, log back in, and then hit the /restart endpoint.
I get the same behaviour. Fresh install on AWS ubuntu 18.04 installing version 2.164.1
I have set locale to en_US.UTF8
I also get errors when I try to create user with passwords containing characters outside ASCII
I understand the reason is an attempt to authenticate the http request after the user list is destroyed. A simple fix would be to catch IllegalStateException in User#getOrCreateById and return null. A better solution would be to create a nullable ExtensionList#lookupSingletonOrNull, use it from User.java and handle null properly in all callers.
Getting this attempting to configure a new install on Windows. Installed the following plugins when I saw this first.
- GitHub
- Bitbucket
I got this too today. And reverted only in plugins folder the github-branch-source.bak. But now the plugin manager does not show up the new version, strange.
I ran into this right after upgrading to 2.164.2 today. Clearing the /caches folder and restarting Jenkins got rid of the error.
EDIT: The error returns every time I reboot Jenkins after updating a plugin. Manually restarting the service (on Windows) fixes it until the next reboot for plugin updates...
I'm taking a look at this to see if I can figure out what's going on. I haven't had any luck at reproducing it yet. There must be something about timing or configuration. There's probably something a little off about the Jenkins init sequence. If anyone could contribute additional logging, particularly showing init sequence progress, that might be helpful. It might be possible to catch the error here and do something, but without reproduction it's difficult to know if we'd be doing the right thing. Catching it and setting the security context to null would probably work.
I can reproduce it every time. I just access the Jenkins URL with "/safeRestart", confirm restart and keep reloading the page every second. It shows the error approximately after 5 to 10 reloads.
It's interesting that I don't see any stack trace in the console log. Jenkins 2.182 in a Docker container.
2019-06-28 21:20:09.963+0000 [id=318] INFO jenkins.model.Jenkins$23#run: Restart in 10 seconds
2019-06-28 21:20:19.964+0000 [id=318] INFO jenkins.model.Jenkins$23#run: Restarting VM as requested by roskinp
2019-06-28 21:20:19.965+0000 [id=318] INFO jenkins.model.Jenkins#cleanUp: Stopping Jenkins
2019-06-28 21:20:19.983+0000 [id=318] INFO jenkins.model.Jenkins$18#onAttained: Started termination
2019-06-28 21:20:19.993+0000 [id=318] INFO jenkins.model.Jenkins$18#onAttained: Completed termination
2019-06-28 21:20:19.993+0000 [id=318] INFO jenkins.model.Jenkins#_cleanUpDisconnectComputers: Starting node disconnection
2019-06-28 21:20:21.011+0000 [id=318] INFO jenkins.model.Jenkins#_cleanUpShutdownPluginManager: Stopping plugin manager
2019-06-28 21:20:21.026+0000 [id=318] INFO jenkins.model.Jenkins#_cleanUpPersistQueue: Persisting build queue
2019-06-28 21:20:21.028+0000 [id=318] INFO jenkins.model.Jenkins#_cleanUpAwaitDisconnects: Waiting for node disconnection completion
2019-06-28 21:20:21.033+0000 [id=318] INFO jenkins.model.Jenkins#cleanUp: Jenkins stopped
Running from: /usr/share/jenkins/jenkins-stable.war
webroot: EnvVars.masterEnvVars.get("JENKINS_HOME")
2019-06-28 21:20:23.482+0000 [id=1] INFO org.eclipse.jetty.util.log.Log#initialized: Logging initialized @595ms to org.eclipse.jetty.util.log.JavaUtilLog
2019-06-28 21:20:23.606+0000 [id=1] INFO winstone.Logger#logInternal: Beginning extraction from war file
2019-06-28 21:20:23.642+0000 [id=1] WARNING o.e.j.s.handler.ContextHandler#setContextPath: Empty contextPath
2019-06-28 21:20:23.704+0000 [id=1] INFO org.eclipse.jetty.server.Server#doStart: jetty-9.4.z-SNAPSHOT; built: 2019-05-02T00:04:53.875Z; git: e1bc35120a6617ee3df052294e433f3a25ce7097; jvm 1.8.0_181-8u181-b13-2~deb9u1-b13
2019-06-28 21:20:24.033+0000 [id=1] INFO o.e.j.w.StandardDescriptorProcessor#visitServlet: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
2019-06-28 21:20:24.087+0000 [id=1] INFO o.e.j.s.s.DefaultSessionIdManager#doStart: DefaultSessionIdManager workerName=node0
2019-06-28 21:20:24.088+0000 [id=1] INFO o.e.j.s.s.DefaultSessionIdManager#doStart: No SessionScavenger set, using defaults
2019-06-28 21:20:24.091+0000 [id=1] INFO o.e.j.server.session.HouseKeeper#startScavenging: node0 Scavenging every 660000ms
Jenkins home directory: /var/jenkins_home found at: EnvVars.masterEnvVars.get("JENKINS_HOME")
Here's what I see on the page. The same Jenkins container.
java.lang.IllegalStateException: Expected 1 instance of hudson.model.User$AllUsers but got 0
at hudson.ExtensionList.lookupSingleton(ExtensionList.java:451)
at hudson.model.User$AllUsers.getInstance(User.java:1080)
at hudson.model.User$AllUsers.get(User.java:1098)
at hudson.model.User$AllUsers.access$100(User.java:1061)
at hudson.model.User.getOrCreateById(User.java:517)
at hudson.model.User.getById(User.java:615)
at hudson.security.HttpSessionContextIntegrationFilter2.hasInvalidSessionSeed(HttpSessionContextIntegrationFilter2.java:87)
at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:60)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:90)
at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:540)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1700)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1345)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:480)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1667)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1247)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:505)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:370)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:267)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:698)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:804)
at java.lang.Thread.run(Thread.java:748)
I tried that same sequence several times and still couldn't reproduce it. Frustrating.
One possible approach might be to catch the exception in `hasInvalidSessionSeed()` and return false. That might do the job, but it's hard to be confident without being able to reproduce the issue. One argument against that approach is that the exception is correct – it's in an invalid state. Ignoring it here may just allow it to continue on to other issues. This one, at least, doesn't seem too hazardous.
Another possible approach might be to wait here until the system gets into a valid state. That sounds risky.
What we really need to do is figure out how it got into the invalid state and handle that.
Yes, I confirm that it works. I patched the code, installed the new jenkins.war, restarted Jenkins 5 times with constant refreshes, did not see the backtrace or the Evil Jenkins picture. Without the patch, the issue is reproducible every time. Here's the patch I used:
diff --git a/core/src/main/java/hudson/security/HttpSessionContextIntegrationFilter2.java b/core/src/main/java/hudson/security/HttpSessionContextIntegrationFilter2.java index 7a67c77dd0..2084651432 100644 --- a/core/src/main/java/hudson/security/HttpSessionContextIntegrationFilter2.java +++ b/core/src/main/java/hudson/security/HttpSessionContextIntegrationFilter2.java @@ -84,7 +84,13 @@ public class HttpSessionContextIntegrationFilter2 extends HttpSessionContextInte return false; } . - User userFromSession = User.getById(authentication.getName(), false); + User userFromSession; + try { + userFromSession = User.getById(authentication.getName(), false); + } catch (IllegalStateException e) { + return false; + } + if (userFromSession == null) { // no requirement for further test as there is no user inside return false;
Thanks proski. That's what I was thinking of trying. At least you can test that it works. Would you like to submit a PR for that? If you do, be sure to @mention me (@jeffret-b on GitHub).
I'm looking into an ATH test that is supposed to duplicate this issue but I haven't been able to get it configured correctly yet.
Inspired by proski's patch, I submitted a PR about this issue: https://github.com/jenkinsci/jenkins/pull/4107
If anyone affected by this issue would like to review, comment, or especially test that proposal, please do.
I was getting the same error as the above. But now after the update, I don't get an error, Jenkins just stays on the restarting screen. This is the info from the err.log:
INFO Restarting VM as requested by user
INFO jenkins.model.Jenkins$18#onAttained: Started termination
INFO jenkins.model.Jenkins#_cleanUpDisconnectComputers: Starting node disconnection
INFO j.s.DefaultJnlpSlaveReceiver#channelClosed: restart thread for Slave1 terminated: java.nio.channels.ClosedChannelException
INFO j.s.DefaultJnlpSlaveReceiver#channelClosed: restart thread for Slave2 terminated: java.nio.channels.ClosedChannelException
INFO j.s.DefaultJnlpSlaveReceiver#channelClosed: restart thread for Slave3 terminated: java.nio.channels.ClosedChannelException
INFO j.s.DefaultJnlpSlaveReceiver#channelClosed: restart thread for Slave4 terminated: java.nio.channels.ClosedChannelException
INFO jenkins.model.Jenkins#_cleanUpShutdownPluginManager: Stopping plugin manager
INFO h.p.virtualbox.VirtualBoxPlugin#stop: Stopping VirtualBoxPlugin
INFO jenkins.model.Jenkins#_cleanUpPersistQueue: Persisting build queue
INFO jenkins.model.Jenkins#_cleanUpAwaitDisconnects: Waiting for node disconnection completion
INFO jenkins.model.Jenkins#cleanUp: Jenkins stopped
WARNING h.s.HttpSessionContextIntegrationFilter2#hasInvalidSessionSeed: Encountered IllegalStateException trying to get a user. System init may not have completed yet. Invalidating user session.
WARNING h.s.HttpSessionContextIntegrationFilter2#hasInvalidSessionSeed: Encountered IllegalStateException trying to get a user. System init may not have completed yet. Invalidating user session.
WARNING h.s.HttpSessionContextIntegrationFilter2#hasInvalidSessionSeed: Encountered IllegalStateException trying to get a user. System init may not have completed yet. Invalidating user session.
WARNING h.s.HttpSessionContextIntegrationFilter2#hasInvalidSessionSeed: Encountered IllegalStateException trying to get a user. System init may not have completed yet. Invalidating user session.
WARNING h.s.HttpSessionContextIntegrationFilter2#hasInvalidSessionSeed: Encountered IllegalStateException trying to get a user. System init may not have completed yet. Invalidating user session.
WARNING h.s.HttpSessionContextIntegrationFilter2#hasInvalidSessionSeed: Encountered IllegalStateException trying to get a user. System init may not have completed yet. Invalidating user session.
WARNING h.s.HttpSessionContextIntegrationFilter2#hasInvalidSessionSeed: Encountered IllegalStateException trying to get a user. System init may not have completed yet. Invalidating user session
The warnings will repeat until I restart the service.
I use Windows server 2012 R2 and Java 8.131
jenkins username is not an admin for security purposes, but has appropriate permissions.
supjac, I was afraid the fix would shift the error around somehow. Since proski reported the fix worked for their scenarios, I decided to submit it to see if it helped some people.
It's interesting that, in your case at least, that it seems to start immediately after the "Jenkins stopped" message. Maybe there's something going on right at the start of the init sequence. Or maybe even before it somehow.
Unfortunately, as I've been unable to reproduce the problem I've gone as far as I can with it. If someone else can figure out how to get more information about it or come with a proposal that would be great.
I'm still with the same problem. I try to configure the artifactory and when I restart the jenkins after install or uninstall the artifactory plugin i got this error:
"
Stack trace
java.lang.IllegalStateException: Expected 1 instance of hudson.model.User$AllUsers but got 0 at hudson.ExtensionList.lookupSingleton(ExtensionList.java:451) at hudson.model.User$AllUsers.getInstance(User.java:1080) at hudson.model.User$AllUsers.get(User.java:1098) at hudson.model.User$AllUsers.access$100(User.java:1061) at hudson.model.User.getOrCreateById(User.java:517) at hudson.model.User.getById(User.java:615) at hudson.security.HttpSessionContextIntegrationFilter2.hasInvalidSessionSeed(HttpSessionContextIntegrationFilter2.java:87) at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:60) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:90) at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610) at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610) at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610) at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:540) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1701) at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1345) at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:480) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1668) at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1247) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) at org.eclipse.jetty.server.Server.handle(Server.java:502) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:370) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:267) at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305) at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126) at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765) at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683) at java.lang.Thread.run(Thread.java:748)
"
gzanella, double-check your versions and make sure you've got the version of Jenkins that contains the change. The line numbers of your stack trace don't line up with changed version.
Jeff Thompson, I did "sudo apt-get upgrade jenkins" and after the upgrade i try to uninstall and install again and got the same error.
"
Stack trace
java.lang.IllegalStateException: Expected 1 instance of hudson.model.User$AllUsers but got 0 at hudson.ExtensionList.lookupSingleton(ExtensionList.java:451) at hudson.model.User$AllUsers.getInstance(User.java:1080) at hudson.model.User$AllUsers.get(User.java:1098) at hudson.model.User$AllUsers.access$100(User.java:1061) at hudson.model.User.getOrCreateById(User.java:517) at hudson.model.User.getById(User.java:615) at hudson.security.HttpSessionContextIntegrationFilter2.hasInvalidSessionSeed(HttpSessionContextIntegrationFilter2.java:87) at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:60) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:90) at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610) at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610) at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610) at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:540) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1701) at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1345) at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:480) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1668) at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1247) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) at org.eclipse.jetty.server.Server.handle(Server.java:502) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:370) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:267) at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305) at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126) at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765) at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683) at java.lang.Thread.run(Thread.java:748)
"
Sorry but I still beginning with this tool and doesn't know much, what I do to fix this? Please..
gzanella, I'm not sure what version that will give you. When you run Jenkins, which version does it say you have?
That explains your observations, gzanella. The change went into the 2.185 weekly release. You've got the latest LTS release, which doesn't have this change. You could request this change be backported to the next incremental release of the LTS. I would be hesitant to backport this, given its experimental nature and we have a report of the change not fixing things for someone. You could switch from using the LTS line to the weekly. See [LTS Release Line](https://jenkins.io/download/lts/) for more information.
so, I have fixed the issue with my jenkins setup.
After looking into the WindowsServiceLifecycle, i noticed that the command to restart was restart! When I tried that in the command line I got my actual error:
Unhandled Exception: System.IO.FileLoadException: Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.
So jenkins was not actually restarting, just getting through the cleanup phase
I installed .net 3.5 but was still getting the same error. I had to modify my Jenkins.exe.config to look like this:
<startup>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
</startup>
Now it is working for me
I have the same problem with Jenkins LTS 2.176.2. Could you please fix that version as well?
simontunnat, you are welcome to request this change be backported. Since supjac, determined their continued failures were unrelated I no longer object to backporting.
simontunnat, as I mentioned above, you can read about the LTS releases, including backports, at https://jenkins.io/download/lts/
The issue is not yet resolved.
We have exactly the same problem as supjac in #comment-371811.
Just updated Jenkins from 2.219 to 2.220, Windows Server 2016 and a dedicated jenkins user.
Jenkins gets into this infinite loop when we try to restart it from the web frontend.
The jenkins service always has to be restarted manually after a jenkins or plugin update.
No problems restarting jenkins from the web frontend when it runs as system user directly after the installation.
2020-02-11 10:38:05.853+0000 [id=770] INFO jenkins.model.Jenkins#cleanUp: Stopping Jenkins
2020-02-11 10:38:05.868+0000 [id=770] INFO jenkins.model.Jenkins$18#onAttained: Started termination
2020-02-11 10:38:05.946+0000 [id=770] INFO jenkins.model.Jenkins$18#onAttained: Completed termination
2020-02-11 10:38:05.946+0000 [id=770] INFO jenkins.model.Jenkins#_cleanUpDisconnectComputers: Starting node disconnection
2020-02-11 10:38:05.962+0000 [id=770] INFO jenkins.model.Jenkins#_cleanUpShutdownPluginManager: Stopping plugin manager
2020-02-11 10:38:05.962+0000 [id=770] INFO jenkins.model.Jenkins#_cleanUpPersistQueue: Persisting build queue
2020-02-11 10:38:05.979+0000 [id=770] INFO jenkins.model.Jenkins#_cleanUpAwaitDisconnects: Waiting for node disconnection completion
2020-02-11 10:38:05.979+0000 [id=770] INFO jenkins.model.Jenkins#cleanUp: Jenkins stopped
2020-02-11 10:38:06.103+0000 [id=12] WARNING h.s.HttpSessionContextIntegrationFilter2#hasInvalidSessionSeed: Encountered IllegalStateException trying to get a user. System init may not have completed yet. Invalidating user session.
2020-02-11 10:38:11.133+0000 [id=603] WARNING h.s.HttpSessionContextIntegrationFilter2#hasInvalidSessionSeed: Encountered IllegalStateException trying to get a user. System init may not have completed yet. Invalidating user session.
2020-02-11 10:38:16.164+0000 [id=632] WARNING h.s.HttpSessionContextIntegrationFilter2#hasInvalidSessionSeed: Encountered IllegalStateException trying to get a user. System init may not have completed yet. Invalidating user session.
2020-02-11 10:38:21.193+0000 [id=12] WARNING h.s.HttpSessionContextIntegrationFilter2#hasInvalidSessionSeed: Encountered IllegalStateException trying to get a user. System init may not have completed yet. Invalidating user session.
2020-02-11 10:38:26.211+0000 [id=603] WARNING h.s.HttpSessionContextIntegrationFilter2#hasInvalidSessionSeed: Encountered IllegalStateException trying to get a user. System init may not have completed yet. Invalidating user session.
luebbe is right - we have the same issue where jenkins.err.log shows:
Encountered IllegalStateException trying to get a user. System init may not have completed yet. Invalidating user session.
We use Jenkins 2.255 on Windows Server 2016
The issue is still there in Jenkins 2.249.1 on Windows Server 2019 and a dedicated jenkins user.
I got the same flood of errors on Jenkins 2.263.1
WARNING h.s.HttpSessionContextIntegrationFilter2#hasInvalidSessionSeed: Encountered IllegalStateException trying to get a user. System init may not have completed yet. Invalidating user session.
Took a look at jenkins.wrapper.log and noticed
2021-01-11 00:37:42,243 FATAL - WMI Operation failure: AccessDenied WMI.WmiException: AccessDenied at WMI.WmiRoot.BaseHandler.CheckError(ManagementBaseObject result) at WMI.WmiRoot.InstanceHandler.Invoke(Object proxy, MethodInfo method, Object[] arguments) at winsw.WrapperService.<Run>g__Restart|33_5(<>c__DisplayClass33_0& ) at winsw.WrapperService.Run(String[] _args, ServiceDescriptor descriptor) at winsw.WrapperService.Main(String[] args)
So it looks like the Web UI /restart endpoint is trying to actually restart a Windows service, for which it does not have permissions if running as a limited user. To fix this, it is possible to run Jenkins as a member of Power Users or Administrators group, but I chose to grant permissions for restarting only the Jenkins service.
Using setacl, to view permissions:
SetACL.exe -on jenkins -ot srv -actn list
To grant service restart permissions ('jenkins' is the name of the service and 'domain\user' should be replaced with actual values):
SetACL.exe -on jenkins -ot srv -actn ace -ace "n:domain\user;p:start_stop;m:grant"
Tried it, and it worked for me.
We no longer have the issue, after applying the fix seen here:
nkjensen unfortunately this didn't help in my case, I still get an IllegalStateException and stuck Jenkins.
Lots of discussion about this on Windows. Are people seeing this on Linux?
Also, below is our exact error. It has the same Expected instance syntax, but it isn't referencing the AllUsers, so I wonder if this is something different.
java.lang.IllegalStateException: Expected 1 instance of jenkins.security.s2m.AdminWhitelistRule but got 0 |
at hudson.ExtensionList.lookupSingleton(ExtensionList.java:451) |
at io.jenkins.plugins.casc.core.AdminWhitelistRuleConfigurator.instance(AdminWhitelistRuleConfigurator.java:59) |
at io.jenkins.plugins.casc.core.AdminWhitelistRuleConfigurator.instance(AdminWhitelistRuleConfigurator.java:42) |
at io.jenkins.plugins.casc.BaseConfigurator.check(BaseConfigurator.java:286) |
at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:351) |
at io.jenkins.plugins.casc.BaseConfigurator.check(BaseConfigurator.java:287) |
at io.jenkins.plugins.casc.ConfigurationAsCode.lambda$checkWith$8(ConfigurationAsCode.java:777) |
at io.jenkins.plugins.casc.ConfigurationAsCode.invokeWith(ConfigurationAsCode.java:713) |
at io.jenkins.plugins.casc.ConfigurationAsCode.checkWith(ConfigurationAsCode.java:777) |
at io.jenkins.plugins.casc.ConfigurationAsCode.configureWith(ConfigurationAsCode.java:762) |
at io.jenkins.plugins.casc.ConfigurationAsCode.configureWith(ConfigurationAsCode.java:638) |
at io.jenkins.plugins.casc.ConfigurationAsCode.configure(ConfigurationAsCode.java:307) |
at io.jenkins.plugins.casc.ConfigurationAsCode.init(ConfigurationAsCode.java:299) |
I'm having the same problem on a RHEL Jenkins:
java.lang.IllegalStateException: Expected 1 instance of jenkins.security.s2m.AdminWhitelistRule but got 0 at hudson.ExtensionList.lookupSingleton(ExtensionList.java:452) at io.jenkins.plugins.casc.core.AdminWhitelistRuleConfigurator.instance(AdminWhitelistRuleConfigurator.java:59) at io.jenkins.plugins.casc.core.AdminWhitelistRuleConfigurator.instance(AdminWhitelistRuleConfigurator.java:42) at io.jenkins.plugins.casc.BaseConfigurator.check(BaseConfigurator.java:285) at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:350) at io.jenkins.plugins.casc.BaseConfigurator.check(BaseConfigurator.java:286) at io.jenkins.plugins.casc.ConfigurationAsCode.lambda$checkWith$8(ConfigurationAsCode.java:776) at io.jenkins.plugins.casc.ConfigurationAsCode.invokeWith(ConfigurationAsCode.java:712) at io.jenkins.plugins.casc.ConfigurationAsCode.checkWith(ConfigurationAsCode.java:776) at io.jenkins.plugins.casc.ConfigurationAsCode.configureWith(ConfigurationAsCode.java:761) at io.jenkins.plugins.casc.ConfigurationAsCode.configureWith(ConfigurationAsCode.java:637) at io.jenkins.plugins.casc.ConfigurationAsCode.configure(ConfigurationAsCode.java:306) at io.jenkins.plugins.casc.ConfigurationAsCode.init(ConfigurationAsCode.java:298)
Hi. I see the ticket, but I have no bandwidth to process it right now.
Will unassign the ticket so that others can work on it if they have some time