“call 'refresh'” error resulting from Grails WAR hot-deploy

女生的网名这么多〃 提交于 2020-01-13 04:56:12

问题


When my Grails WAR is hot-deployed to Tomcat and I refresh the page, I get this error:

1 Feb, 2010 7:00:51 PM org.apache.catalina.core.ApplicationDispatcher invoke SEVERE: Servlet.service() for servlet view-servlet threw exception 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:15

This error does not persist when Tomcat is restarted.


回答1:


ApplicationContext ctx = new ClassPathXmlApplicationContext();

Spring try to lookup the applicationContext.xml from the CLASSPATH, if the xml file can't be found, "BeanFactory not initialized or already closed" error will be thrown out. That is why you restart the tomcat it works just fine. However I don't know the real cause why the applicationContext.xml is not in the classpath during hot-deploy.

If you are running only one Grails application in your tomcat, you can try to put the applicationContext.xml in Tomcat classpath and try hot-deploy again.



来源:https://stackoverflow.com/questions/2177563/call-refresh-error-resulting-from-grails-war-hot-deploy

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!