Confluence does not start due to Spring Application context has not been set

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Problem

On Confluence Startup, the following error is thrown: 

atlassian-confluence.log
2010-06-18 21:54:45,432 INFO [main] [com.atlassian.confluence.lifecycle] init Confluence is ready to serve
2010-06-18 21:55:20,515 FATAL [http-8080-1] [atlassian.spring.container.SpringContainerContext] getComponent Spring Application context has not been set
2010-06-18 21:55:20,528 ERROR [http-8080-1] [[Standalone].[localhost].[/].[action]] log Servlet.service() for servlet action threw exception
java.lang.IllegalStateException: Spring Application context has not been set
	at com.atlassian.spring.container.SpringContainerContext.getComponent(SpringContainerContext.java:48)
	at com.atlassian.spring.container.ContainerManager.getComponent(ContainerManager.java:32)
	at com.atlassian.confluence.security.seraph.ConfluenceElevatedSecurityGuard.getCaptchaManager(ConfluenceElevatedSecurityGuard.java:115)   

This error may also be thrown: 

catalina.out
15-Nov-2015 23:57:33.447 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Tomcat-Standalone
15-Nov-2015 23:57:33.447 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.28
2015-11-15 23:57:45,736 INFO [localhost-startStop-1] [com.atlassian.confluence.lifecycle] contextInitialized Starting Confluence 5.8.16 [build 5996 based on commit hash 4a6343ec7ed8542179d6c78fa7f87c01f81da016]
15-Nov-2015 23:58:06.434 SEVERE [Standalone-startStop-1] org.apache.catalina.startup.HostConfig.start Unable to create directory for deployment: /opt/atlassian/confluence/conf/Standalone/localhost

This error may also be thrown:

java.util.concurrent.CompletionException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tenantedTransactionManager' defined in class path resource [databaseSubsystemContext.xml]: Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tenantedLocalSessionFactoryBean5' defined in class path resource [productionDatabaseContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: premature SessionFactory initialisation, Hibernate properties have not yet been persisted in confluence.cfg.xml

or during installation after a restart

2016-11-30 12:23:12,241 ERROR [http-nio-8090-exec-3] [confluence.util.profiling.ConfluenceSitemeshErrorDecorator] renderInternal Failed to render error decorator. Falling back to using no decorator
 -- traceId: 006cacff18fcfffe
javax.servlet.ServletException: org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getLocale' in  class com.atlassian.confluence.core.ConfluenceActionSupport threw exception java.lang.IllegalStateException: Spring Application context has not been set at /decorators/includes/header.vm[line 58, column 41]

Cause

  1. The user running Confluence does not have write permissions to the home folder defined in <install>/confluence/WEB-INF/classes/confluence-init.properties or the install directory.
  2. You are running Confluence as the root user or if you have an application firewall enabled (SeLinux or AppArmor).
  3. The database driver is not located in the <install>/confluence/WEB-INF/lib folder or you are using a database version that is incompatible with the bundled driver. 
  4. The hostname of the server can not be resolved.
  5. The server does not have enough memory during installation to set up the database, and restarts return this error.
  6. After upgrading the OS, the installation directory might become defective.
  7. The Confluence database is not configured correctly with permissions.
  8. The file <confluence-home>/confluence.cfg.xml is corrupt.
  9. When running a Data Center distribution and the network interface configured in the affected node is different than the one used in the other nodes.
  10. Confluence is actively being monitored by a health check from a load balancer, other users are accessing confluence or other browser tabs are refreshing the confluence base URL.
  11. Using MySQL database, either the collation or character set properties are not set correctly.
  12. The Setup Wizard requires fulfilling a certain number of steps. For whatever reason, the Confluence instance has been stopped or the server has been restarted before finishing all the steps of the Setup Wizard.

    Each step can be identified by checking the URL in the web browser. A typical Confluence installation would go through the following URLs (they may vary depending on the options you choose):

    • <base-url>/setup/setupstart.action

    • <base-url>/setup/selectbundle.action
    • <base-url>/setup/setuplicense.action
    • <base-url>/setup/setupcluster.action
    • <base-url>/setup/setupcluster-start.action - DC
    • <base-url>/setup/setupdbchoice-start.action - DC
    • <base-url>/setup/setupdata-start.action - DC
    • <base-url>/setup/finishsetup.action - DC
    • <base-url>/setup/setupdbtype-start.action
    • <base-url>/setup/setupdata-start.action
    • <base-url>/setup/setupusermanagementchoice-start.action
    • <base-url>/setup/complete.action

Resolution

Resolution 1

Linux

Do not run Confluence as root, and ensure that the user running Confluence has full read and write access to the home folder. This can be set by running chmod -R with the appropriate permissions, to apply them recursively to each subfolder. An example of the right permissions would be:

sudo chown -R <confluence-user> <confluence-install-folder>
sudo chown -R <confluence-user> <confluence-home-folder>
sudo chmod -R u=rwx,g=rx,o=rx <confluence-install-folder>
sudo chmod -R u=rwx,g=rx,o=rx <confluence-home-folder>

The user confluence is only a suggestion. You can change it for another username.

Windows

  • Right-click the <Confluence Home> Folder
  • Select Properties
  • Select Security
  • Add the user that is being used to run Confluence with full read and write access

Resolution 2

If even with the right permissions you still are facing issues, check out this documentation to verify if there is a SeLinux or AppArmor enabled.

Resolution 3

Check the Supported Platforms and Database JDBC Drivers pages and verify that the required driver is located under <install>/confluence/WEB-INF/lib and your database version is compatible with the Confluence version.

Resolution 4

The hostname you are using must be resolvable (try ping $HOSTNAME). E.g.  The hostname  localhost  has not been added to  /etc/hosts . See java.net.UnknownHostException exceptions in Confluence log file due to DNS lookups failing.

Resolution 5

Confirm your server has enough physical memory to run the JVM. Confluence 6.0 requires 2GB. Before re-starting the installer, restart the Setup Wizard by following the steps outlined in Resolution 10. 

Resolution 6

Reinstall Confluence using a new installation directory and a different home directory. Check if the folder permission for the installer and home directories are correct. Check if the UI comes up as expected using the new installation directory and after finishing the setup, stop confluence and modify the <install>/confluence/WEB-INF/classes/confluence-init.properties file pointing to the old home directory. Save the file and start the application again.

Resolution 7

It is recommended that the database user is the owner of the Confluence database. When using PostgreSQL, the user has to be the owner of the Confluence database. Oracle, MySQL, and MSSQL need only the necessary permissions.

Resolution 8

The <confluence-home>/confluence.cfg.xml file needs to be properly formatted. It can be checked using online tools like W3 School XML Validator or advanced editors like IntelliJ or Eclipse. The file might have some hidden characters like "space" in the wrong place (e.g before the opening <?xml....> or some elements might not be closed properly which can break the XML file format.

Please note that confluence.cfg.xml can hold sensitive information (e.g. passwords) and because of that, we advise you to remove them (sensitive information) prior to testing it with online tools.


Resolution 9

The interface name might have been named in a different order for the affected server compared to the others, which means that an interface named eth2 in one server could be the same interface that is named eth3 in another server.
In this case, we'll need to find out which interface is the correct one on the affected server. Please, follow the resolution steps outlined in this KB article to find it out, then change the confluence.cfg.xml file to use the proper network interface: https://confluence.atlassian.com/confkb/hazelcast-cannot-start-on-this-node-no-matching-network-interface-found-646447553.html

Resolution 10

It is recommended that only one Browser window is connected to Confluence during the initial installation wizard and that no other user or health check is targeting the Confluence instance. Multiple open browser windows will be polling the Server for a status update which may affect the Setup and result in a Spring Context error as per  CONFSERVER-59084 - Getting issue details... STATUS

Resolution 11

If you're running a MySQL database, please check the collation and character set of the database and verify:

  • <charset> is set to either utf8 or utf8mb4
  • <collation> is set to either utf8_bin or utf8mb4_bin

See How to Fix the Collation and Character Set of a MySQL Database manually for more information.

Resolution 12

If this is a fresh installation, you can use the steps below to restart the installation. (warning) This will completely wipe the original instance and data in the database.

  1. Stop Confluence.

  2. Backup and delete the <confluence-home>/confluence.cfg.xml file.

  3. Start Confluence.

  4. Access the Base URL in your browser to start the Setup Wizard from the beginning.

  5. During the database configuration step, choose "Continue and overwrite existing data" if prompted.

  6. Make sure all the steps are completed successfully.
DescriptionOn Confluence Startup, an error is thrown: Spring Application context has not been set.
ProductConfluence
PlatformServer
Last modified on Oct 12, 2022

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.