Issue
Sorry for my English. I use Eclipse 3.7
, that runs web-app (spring-mvc
+ spring-secirity
) on tomcat6
, but happens next error:
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:1071)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1045)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:993)
at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:548)
at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:142)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4245)
at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4886)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4750)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
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(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Can anyone help me please?
Solution
I have seen this stacktrace before when working on a project that uses Spring 3.0.6
and runs in JBoss
.
When I have seen this, it was inevitably in conjunction with database connectivity or permission issues.
Here is another developer who encountered this issue and it was also related to communication with the database: How can I cope with “IllegalStateException: BeanFactory not initialized or already closed”?
There is another developer on this thread who commented that he had a similar exception, and his was caused by a bad Spring Security configuration file.
Also, you may want to check into where you have placed the Spring JARs. Here is a relevant post: Spring Tomcat issue.
Finally, there are certain versions of application servers where this error could be caused by a bug in the application server. Here is a post on SpringSource forums regarding a bug in Weblogic 9.2 MP2. Here is another post regarding a bug in a particular version of jbossws.
Good luck, hope this helps.
Answered By - Philip Tenn