开发者

Grails production WAR in tomcat6, hot re-deploment error: call 'refresh' before accessing beans via the ApplicationContext

I have a grails WAR that works in production in tomcat6, but when I go to redeploy the WAR, I overwrite the WAR files. The app reloads and I can load the front page (static page) but then when I try go to any other page I get this warning.

org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException: Error executing tag <g:render>: Error creating bean with name 'or开发者_运维知识库g.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib': Instantiation of bean failed; nested exception is java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext at /WEB-INF/grails-app/views/layouts/baseContainer.gsp:28

        at gsp_app_layoutsbaseContainerMapFb_gsp$_run_closure2.doCall(gsp_app_layoutsbaseContainer_gsp.groovy:42)

        at gsp_app_layoutsbaseContainerMapFb_gsp$_run_closure2.doCall(gsp_app_layoutsbaseContainer_gsp.groovy)

        at gsp_app_layoutsbaseContainerMapFb_gsp.run(gsp_app_layoutsbaseContainerMa_gsp.groovy:49)

        at java.lang.Thread.run(Unknown Source)

    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib': Instantiation of bean failed; nested exception is java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext

        at gsp_app_templates_facebookConnect_gsp.run(gsp_app_templates_facebookConnect_gsp.groovy:23)

        ... 4 more

    Caused by: java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext

What am I don't wrong? How can I call this so called "refresh"?

Whats the best way to hot redeploy WAR's on tomcat?


We'll probably not be able to resolve this at Stackoverflow. I hope you'll grade my support attempt, though, if you cannot find better information.

First, the Grails documentation suggests to restart Tomcat after (re-)deployment. But this shouldn't be necessary in most cases.

When Tomcat reloads the web application, a Grails ServletContextListener gets informed about that event and creates (should create) the Grails/Spring ApplicationContext that wires all the application's Spring beans (by using the aforementioned refresh(..) method, BTW). This goes wrong in your case.

Normally, after hot-deployment, you'll just have to wait a while until the ApplicationContext is completely available, but it should be after some time, finally. In between these two states, your error would be normal. Spring is working on the problem (for quite some time now) to make Spring's DispatcherServlet wait for the second state even when requests come in before that. So this is considered an improvement, not a bug.

As for the deployment process to Tomcat itself, see the Tomcat documentation. By default, hot-deployment should be as easy as overwriting an existing WAR file and letting Tomcat unpack it, but that can be customized on the <Host> tag in conf/server.xml.

Other ideas:

  • I guess you did wait long enough after re-deployment to make sure the error doesn't occur for a limited time, only.
  • You could post the complete stacktrace.
  • In the web.xml file of your WAR, are there any <listener>s or <filter>s that do not belong to the namespace org.codehaus...?
  • Do you use any special plugins, versions, specifications?
  • If you've setup a virtual host in Tomcat, have some look at the autoDeploy and unpackWAR settings.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜