Getting Spring Application context has not been set Error
Asked by kiriinfotech:

Hi Team,

I am getting below error while I am trying to start the self-hosted Confluence server.

com.atlassian.util.concurrent.LazyReference$InitializationException: java.lang.IllegalStateException: Spring Application context has not been set  
at com.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:149)

caused by: java.lang.IllegalStateException: Spring Application context has not been set  
at com.atlassian.spring.container.SpringContainerContext.getComponent(SpringContainerContext.java:48)

I have installed Confluence on Windows with Mysql As a database, But I am getting above error when my server got restarted.

I have tried reinstalling the server but still, the issue is same and we are unable to solve this issue.

I have tried almost all the solutions that are mentioned in the below forum

<https://confluence.atlassian.com/confkb/confluence-does-not-start-due-to-spring-application-context-has-not-been-set-218278311.html?_ga=2.12609649.752811573.1560337344-924175639.1560337344>

To check the complete error please access below URL

\[redacted\]


Answers:
author: Stephen Sifers
body: Hello Pratik,

Thank you for clarifying the error along with sending the logs. The document you included has multiple steps to be tested on your instance. With this said I would like to focus on resolution 8 which discusses the confluence.cfg.xml file itself. Ensure you have a good backup of your server and Confluence instance prior to moving forward.

Here is how to generate a new confluence.cfg.xml file:

1. Back up your production database and Confluence home directory.
2. Create a new, blank database. This is solely for creating the new confluence.cfg.xmlfile and will be discarded later.
3. Create a temporary home directory. This is solely for creating the new confluence.cfg.xml file and will be discarded later.
4. Edit \<confluence_install_directory\>/confluence/WEB-INF/classes/confluence-init.properties by changing it to point to the temporary home directory you created in Step 3.
5. Start Confluence.
6. Go through the Setup Wizard. On the database configuration screen, point Confluence to the database you created in Step 2.
7. Complete the Setup Wizard.
8. Once the installation is complete, shut down Confluence.
9. At this point, you should have a brand new Confluence installation with a temporary home directory containing a new (and complete) confluence.cfg.xml file.
10. Copy that file to your actual home directory (the one you backed up in Step1). Delete the old confluence.cfg.xml file if it exists.
11. Modify the new confluence.cfg.xml file by changing the database connection string so that it's pointing to your production DB.
12. Modify \<confluence_install_directory\>/confluence/WEB-INF/classes/confluence-init.properties again by pointing it back to your existing Confluence home.
13. Start Confluence.

Source documentation: [How to Generate a New confluence.cfg.xml](https://confluence.atlassian.com/confkb/how-to-generate-a-new-confluence-cfg-xml-425461512.html)

Once you complete the above please let us know if Confluence is able to start without issue.

Regards,  
Stephen Sifers


Tags: confluence-server

server