Answers: <p>After much investigation, I came across the fact that some plugins, specifically the Matrix Authorization Strategy Plugin and role-strategy-plugin were in a deadlock state where they both would not be checked under &quot;compatible&quot; to update, as they were dependent on each other being updated.</p>
  <p>Being fairly knew to Jenkins, and not wanting to break things, I only updated the compatible plugins, however; I missed this deadlock type issue.</p>
  <p>Updating both of these plugins fixed the issue.</p>
  
Answers: CC BY-SA 4.0
Answers: 2022-04-07T20:33:35.813Z
Answers: Thanks for sharing this answer to your own question. Make sure to mark it accepted also (after the system allows you to do so (I think as of tomorrow).
Answers: Pierre.Vriens
Answers: CC BY-SA 4.0
Answers: 2022-04-07T18:20:53.340Z
Answers: 2022-04-07T18:20:53.340Z
Answers: jander69
Answers: <p>Adding to @jander69 research,</p>
  <p>I performed the below steps and it worked:</p>
  <ol>
  <li><p>Stop the jenkins server using <code>jenkins.exe stop</code> command.</p>
  </li>
  <li><p>In the jenkins installation folder, open <code>Plugins</code> folder and delete below listed plugins and their <code>.jpi</code> files.</p>
  <p>i. <code>role-strategy</code> folder and <code>role-strategy.jpi</code></p>
  <p>ii. <code>matrix-auth</code> folder and <code>matrix-auth.jpi</code></p>
  </li>
  <li><p>In the same jenkins installation folder, open <code>config.xml</code> file in any editor.</p>
  </li>
  <li><p>Delete the section with tag <code>&lt;authorizationStrategy&gt; ... &lt;/authorizationStrategy&gt;</code> and save <code>config.xml</code> file.</p>
  </li>
  <li><p>Start the jenkins server using <code>jenkins.exe start</code> command.</p>
  </li>
  </ol>
  <p>Now, Jenkins should load as expected without the <code>IllegalStateException: An attempt to save the global configuration was made before it was loaded</code> error.</p>
  
Answers: CC BY-SA 4.0
Answers: 2022-06-06T17:22:02.820Z
Answers: Thank you for adding to this, that will go one step farther by removing the plugins themselves as well.  Still not an actual "solution" as it leaves you without your roles, but at least it gives you a place to work from rather than an error screen...
Answers: jander69
Answers: CC BY-SA 4.0
Answers: 2022-06-05T16:53:07.187Z
Answers: 2022-06-05T16:53:07.187Z
Answers: Sai Charan Uppari
Body: <p>I recently upgraded Jenkins from 2.204.4 to 2.332.1.  In doing so, I received the following error.</p>
  <pre><code>java.lang.IllegalStateException: An attempt to save the global configuration was made before it was loaded
      at jenkins.model.Jenkins.save(Jenkins.java:3519)
      at jenkins.model.Jenkins.saveQuietly(Jenkins.java:3546)
      at jenkins.model.Jenkins.setSecurityRealm(Jenkins.java:2743)
      at jenkins.model.Jenkins$15.run(Jenkins.java:3481)
      at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:175)
      at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:305)
      at jenkins.model.Jenkins$5.runTask(Jenkins.java:1156)
      at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:222)
      at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:121)
      at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
  Caused: org.jvnet.hudson.reactor.ReactorException
      at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:291)
      at jenkins.InitReactorRunner.run(InitReactorRunner.java:49)
      at jenkins.model.Jenkins.executeReactor(Jenkins.java:1191)
      at jenkins.model.Jenkins.&lt;init&gt;(Jenkins.java:981)
      at hudson.model.Hudson.&lt;init&gt;(Hudson.java:86)
      at hudson.model.Hudson.&lt;init&gt;(Hudson.java:82)
      at hudson.WebAppMain$3.run(WebAppMain.java:247)
  Caused: hudson.util.HudsonFailedToLoad
      at hudson.WebAppMain$3.run(WebAppMain.java:264)
  </code></pre>
  <p>I was able to &quot;fix&quot; this by commenting out the  and  blocks in config.xml, but that had the side effect of wiping out our Active Directory settings as well as all Role Based permissions.</p>
  <p>I saved the settings, so I was able to manually set everything back up, but now after a Jenkins reboot, I get the same error.</p>
  <p>I noticed in the Jenkins error log it is throwing the following error for all users on startup</p>
  <pre><code>SEVERE  hudson.model.User#loadFromUserConfigFile: Failed to load E:\jenkins\users\{user}\config.xml
  java.nio.channels.ClosedByInterruptException
  </code></pre>
  <p>I am rather new to Jenkins, so I am not sure what would be causing this.  Has anyone encountered this or know of a fix?</p>
  <p>Edit: As mentioned in my comment I discovered the error is due to the role-strategy plugin.  I attempted to use the Configuration as Code plugin, thinking that this would load the config.xml settings at the correct time, but that is not the case.</p>
  <p>The issue is that there is still info in <code>&lt;authorizationStrategy&gt;</code> block in config.xml when Jenkins restarts...  is there a way to clear that?</p>
  
Comments: CC BY-SA 4.0
Comments: 2022-04-07T14:49:57.410Z
Comments: Upon further investigation today, I enabled Active Directory but changed the Authorization Strategy to "Anyone can do Anything" and attempted a restart.  I did not receive the error, therefore I suppose the issue would be coming from the role-strategy-plugin...
Comments: jander69
Tags: <jenkins>
Title: How to solve my error about saving the global configuration before it is loaded in Jenkins?
UserDisplayName: jander69
ThreadText: # How to solve my error about saving the global configuration before it is loaded in Jenkins?
  
  (Asked by: username_0 on 2022-04-06)
  
  I recently upgraded Jenkins from 2.204.4 to 2.332.1. In doing so, I received the following error.
  
  ```
  java.lang.IllegalStateException: An attempt to save the global configuration was made before it was loaded
      at jenkins.model.Jenkins.save(Jenkins.java:3519)
      at jenkins.model.Jenkins.saveQuietly(Jenkins.java:3546)
      at jenkins.model.Jenkins.setSecurityRealm(Jenkins.java:2743)
      at jenkins.model.Jenkins$15.run(Jenkins.java:3481)
      at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:175)
      at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:305)
      at jenkins.model.Jenkins$5.runTask(Jenkins.java:1156)
      at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:222)
      at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:121)
      at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
  Caused: org.jvnet.hudson.reactor.ReactorException
      at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:291)
      at jenkins.InitReactorRunner.run(InitReactorRunner.java:49)
      at jenkins.model.Jenkins.executeReactor(Jenkins.java:1191)
      at jenkins.model.Jenkins.<init>(Jenkins.java:981)
      at hudson.model.Hudson.<init>(Hudson.java:86)
      at hudson.model.Hudson.<init>(Hudson.java:82)
      at hudson.WebAppMain$3.run(WebAppMain.java:247)
  Caused: hudson.util.HudsonFailedToLoad
      at hudson.WebAppMain$3.run(WebAppMain.java:264)
  
  ```
  
  I was able to "fix" this by commenting out the and blocks in config.xml, but that had the side effect of wiping out our Active Directory settings as well as all Role Based permissions.
  
  I saved the settings, so I was able to manually set everything back up, but now after a Jenkins reboot, I get the same error.
  
  I noticed in the Jenkins error log it is throwing the following error for all users on startup
  
  ```
  SEVERE  hudson.model.User#loadFromUserConfigFile: Failed to load E:\jenkins\users\{user}\config.xml
  java.nio.channels.ClosedByInterruptException
  
  ```
  
  I am rather new to Jenkins, so I am not sure what would be causing this. Has anyone encountered this or know of a fix?
  
  Edit: As mentioned in my comment I discovered the error is due to the role-strategy plugin. I attempted to use the Configuration as Code plugin, thinking that this would load the config.xml settings at the correct time, but that is not the case.
  
  The issue is that there is still info in `<authorizationStrategy>` block in config.xml when Jenkins restarts... is there a way to clear that?
  
  **Tags:** jenkins
  
  > **Comments:**
  > **username_0**: Upon further investigation today, I enabled Active Directory but changed the Authorization Strategy to "Anyone can do Anything" and attempted a restart.  I did not receive the error, therefore I suppose the issue would be coming from the role-strategy-plugin...  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2022-04-07. Score: 2 | Accepted answer
  
  After much investigation, I came across the fact that some plugins, specifically the Matrix Authorization Strategy Plugin and role-strategy-plugin were in a deadlock state where they both would not be checked under "compatible" to update, as they were dependent on each other being updated.
  
  Being fairly knew to Jenkins, and not wanting to break things, I only updated the compatible plugins, however; I missed this deadlock type issue.
  
  Updating both of these plugins fixed the issue.
  
  > **Comments:**
  > **username_1**: Thanks for sharing this answer to your own question. Make sure to mark it accepted also (after the system allows you to do so (I think as of tomorrow).  
  
  ---
  
  ### Answer by username_2 on 2022-06-05. Score: 1
  
  Adding to @username_0 research,
  
  I performed the below steps and it worked:
  
  1. Stop the jenkins server using `jenkins.exe stop` command.
  2. In the jenkins installation folder, open `Plugins` folder and delete below listed plugins and their `.jpi` files.
  
     i. `role-strategy` folder and `role-strategy.jpi`
  
     ii. `matrix-auth` folder and `matrix-auth.jpi`
  3. In the same jenkins installation folder, open `config.xml` file in any editor.
  4. Delete the section with tag `<authorizationStrategy> ... </authorizationStrategy>` and save `config.xml` file.
  5. Start the jenkins server using `jenkins.exe start` command.
  
  Now, Jenkins should load as expected without the `IllegalStateException: An attempt to save the global configuration was made before it was loaded` error.
  
  > **Comments:**
  > **username_0**: Thank you for adding to this, that will go one step farther by removing the plugins themselves as well.  Still not an actual "solution" as it leaves you without your roles, but at least it gives you a place to work from rather than an error screen...  
  
  ---
  
  