“呼叫'刷新'” Grails WAR热部署导致的错误 [英] "call 'refresh'" error resulting from Grails WAR hot-deploy

查看:266
本文介绍了“呼叫'刷新'” Grails WAR热部署导致的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我的Grails WAR被热部署到Tomcat并刷新页面时,出现此错误:


2010年2月1日7:00:51 PM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE:Servlet.service()用于servlet view-servlet抛出异常
java.lang.IllegalStateException:BeanFactory未初始化或者已经关闭 - 在通过ApplicationContext访问Bean之前调用'refresh'
at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:15


blockquote>

当Tomcat重新启动时,此错误不会持续。

解决方案

ApplicationContext ctx = new ClassPathXmlApplicationContext();

Spring尝试从CLASSPATH中查找applicationContext.xml,如果找不到xml文件,BeanFactory未初始化或已关闭错误将被抛出,这就是为什么你重新启动tomcat它工作得很好。不过,我不知道为什么在热部署期间applicationContext.xml不在类路径中的真正原因。



如果您在tomcat中只运行一个Grails应用程序,则可以尝试将applicationContext.xml放入Tomcat类路径中,然后再次尝试热部署。

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.

解决方案

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.

这篇关于“呼叫'刷新'” Grails WAR热部署导致的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆