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 web27312

  • BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
  • via GitHub by anfe0690
    , 2 months ago
    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
  • 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:534) at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:142) at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4244) at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4879) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4749) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675) at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1315) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061) at org.apache.catalina.core.StandardHost.start(StandardHost.java:840) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

    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, 11 months ago
    Unknown user
    Once, 1 year ago
    Unknown user
    Once, 1 year ago
    Unknown user
    Once, 1 year ago
    Unknown user
    Once, 1 year ago
    156 more bugmates