java.lang.IllegalStateException

BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext

Samebug tips2

Execute mvn dependency:tree from your project's root directory.


The application is unable to connect to the database. It could be resolved by configuring access privileges on the database side.


Don't give up yet. Our experts can help. Paste your full stack trace to get a solution.

Solutions on the web27286

  • BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
  • BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
  • via Google Groups by Emil Hedenberg, 1 month ago
    BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
  • Stack trace

    • java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:172) at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1066) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1040) at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:988) at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:541)

    Write tip

    You have a different solution? A short tip here would help you and many other users who saw this issue last week.

    Users with the same issue

    Unknown user
    Once, 1 year ago
    Unknown user
    Once, 1 year ago
    Unknown user
    Once, 2 months ago
    Unknown user
    Once, 10 months ago
    Unknown user
    2 times, 10 months ago
    155 more bugmates