Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-55945

Got IllegalStateException while restart Jenkins

    XMLWordPrintable

    Details

    • Similar Issues:
    • Released As:
      Jenkins 2.185

      Description

      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

        Attachments

          Activity

          Hide
          ethorsa ethorsa added a comment -

          I can confirm the problem on windows hosted Jenkins v2.235.5.

          Show
          ethorsa ethorsa added a comment - I can confirm the problem on windows hosted Jenkins v2.235.5.
          Hide
          nkjensen Niels Kristian Jensen added a comment - - edited

          The issue is still there in Jenkins 2.249.1 on Windows Server 2019 and a dedicated jenkins user.

          Show
          nkjensen Niels Kristian Jensen added a comment - - edited The issue is still there in Jenkins 2.249.1 on Windows Server 2019 and a dedicated jenkins user.
          Hide
          altxt Alex added a comment -

          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.

          Show
          altxt Alex added a comment - 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.
          Show
          nkjensen Niels Kristian Jensen added a comment - We no longer have the issue, after applying the fix seen here: https://issues.jenkins.io/browse/JENKINS-50219?focusedCommentId=338697&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-338697
          Hide
          ethorsa ethorsa added a comment -

          Niels Kristian Jensen unfortunately this didn't help in my case, I still get an IllegalStateException and stuck Jenkins.

          Show
          ethorsa ethorsa added a comment - Niels Kristian Jensen  unfortunately this didn't help in my case, I still get an IllegalStateException and stuck Jenkins.

            People

            Assignee:
            jthompson Jeff Thompson
            Reporter:
            artem_fedorov Artem Fedorov
            Votes:
            16 Vote for this issue
            Watchers:
            28 Start watching this issue

              Dates

              Created:
              Updated: