Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-6520

Upgrading from Sping 2.5.6 to 3.0RC3 on WAS 6.1 with an ear.context results in a startup exception

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 3.0 RC3
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      My web.xml has:

      <context-param>
      <param-name>parentContextKey</param-name>
      <param-value>ear.context</param-value>
      </context-param>

      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:171)
      at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1008)
      at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:397)
      at org.springframework.web.context.ContextLoader.loadParentContext(ContextLoader.java:343)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:188)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
      at com.ibm.ws.wswebcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:653)
      at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinish(WebApp.java:370)
      at com.ibm.ws.wswebcontainer.webapp.WebApp.initialize(WebApp.java:293)
      at com.ibm.ws.wswebcontainer.webapp.WebGroup.addWebApplication(WebGroup.java:93)
      at com.ibm.ws.wswebcontainer.VirtualHost.addWebApplication(VirtualHost.java:162)
      at com.ibm.ws.wswebcontainer.WebContainer.addWebApp(WebContainer.java:673)
      at com.ibm.ws.wswebcontainer.WebContainer.addWebApplication(WebContainer.java:626)
      at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:335)
      at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:551)

        Activity

        Hide
        grant.gochnauer Grant Gochnauer added a comment -

        The Spring JARs live at the EAR level and so does the JAR which contains my beanRefContext.xml.

        The beanRefContext.xml only has this:

        <!-- This bean is the parent ApplicationContext for the WebApplicationContexts defined in the WARs.
        The context files listed here should contain beans that are used by all WARs,
        for example Services and DAO's. -->
        <!--suppress SpringBeanNameConventionInspection -->
        <bean id="ear.context" class="org.springframework.context.support.ClassPathXmlApplicationContext">
        <constructor-arg>
        <list>
        <value>com/xxxx/cwp/tool/onlineorder/applicationContext.xml</value>
        </list>
        </constructor-arg>
        </bean>

        Show
        grant.gochnauer Grant Gochnauer added a comment - The Spring JARs live at the EAR level and so does the JAR which contains my beanRefContext.xml. The beanRefContext.xml only has this: <!-- This bean is the parent ApplicationContext for the WebApplicationContexts defined in the WARs. The context files listed here should contain beans that are used by all WARs, for example Services and DAO's. --> <!--suppress SpringBeanNameConventionInspection --> <bean id="ear.context" class="org.springframework.context.support.ClassPathXmlApplicationContext"> <constructor-arg> <list> <value>com/xxxx/cwp/tool/onlineorder/applicationContext.xml</value> </list> </constructor-arg> </bean>
        Hide
        grant.gochnauer Grant Gochnauer added a comment -

        the title of this issue should have read "ear.context" not "ejb.context". Typo

        Show
        grant.gochnauer Grant Gochnauer added a comment - the title of this issue should have read "ear.context" not "ejb.context". Typo
        Hide
        juergen.hoeller Juergen Hoeller added a comment -

        Hmm I can't see an obvious change that could be causing this. The whole BeanFactoryLocator area saw no significant changes since 2.5.6, and basic ContextSingletonBeanFactoryLocator usage does work for me locally. So the change is probably somewhere in ClassPathXmlApplicationContext's base classes...

        Whenever that useBeanFactory call comes in, the underlying ApplicationContext must have been refreshed already through SingletonBeanFactoryLocator's initializeDefinition. I wonder whether we are facing a concurrency issue here: How can useBeanFactory ever receive an ApplicationContext reference that hasn't been fully refreshed before?

        You could try to debug and see what state of ApplicationContext you're getting there... I'm sure this isn't a big deal to fix for 3.0 GA still - once we identified the actual cause.

        Juergen

        Show
        juergen.hoeller Juergen Hoeller added a comment - Hmm I can't see an obvious change that could be causing this. The whole BeanFactoryLocator area saw no significant changes since 2.5.6, and basic ContextSingletonBeanFactoryLocator usage does work for me locally. So the change is probably somewhere in ClassPathXmlApplicationContext's base classes... Whenever that useBeanFactory call comes in, the underlying ApplicationContext must have been refreshed already through SingletonBeanFactoryLocator's initializeDefinition. I wonder whether we are facing a concurrency issue here: How can useBeanFactory ever receive an ApplicationContext reference that hasn't been fully refreshed before? You could try to debug and see what state of ApplicationContext you're getting there... I'm sure this isn't a big deal to fix for 3.0 GA still - once we identified the actual cause. Juergen
        Hide
        grant.gochnauer Grant Gochnauer added a comment -

        Let me try to debug today.

        Show
        grant.gochnauer Grant Gochnauer added a comment - Let me try to debug today.
        Hide
        grant.gochnauer Grant Gochnauer added a comment -

        Juergen,

        I can no longer reproduce this issue. I must have had some weird issue going on at the time but this is working as expected now.

        Thanks!

        Show
        grant.gochnauer Grant Gochnauer added a comment - Juergen, I can no longer reproduce this issue. I must have had some weird issue going on at the time but this is working as expected now. Thanks!
        Hide
        juergen.hoeller Juergen Hoeller added a comment -

        Thanks, Grant - good to hear that it works for you now! Let me know if it ever reappears...

        Juergen

        Show
        juergen.hoeller Juergen Hoeller added a comment - Thanks, Grant - good to hear that it works for you now! Let me know if it ever reappears... Juergen
        Hide
        grant.gochnauer Grant Gochnauer added a comment -

        This just happened again when I deployed an EAR that had 5 web apps in it all using spring and the ear.context.

        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:171)
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1008)
        at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:397)
        at org.springframework.web.context.ContextLoader.loadParentContext(ContextLoader.java:343)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:188)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
        at com.ibm.ws.wswebcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:653)
        at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinish(WebApp.java:370)

        Show
        grant.gochnauer Grant Gochnauer added a comment - This just happened again when I deployed an EAR that had 5 web apps in it all using spring and the ear.context. 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:171) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1008) at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:397) at org.springframework.web.context.ContextLoader.loadParentContext(ContextLoader.java:343) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:188) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) at com.ibm.ws.wswebcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:653) at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinish(WebApp.java:370)
        Hide
        grant.gochnauer Grant Gochnauer added a comment -

        What's strange is that if I remove the EAR and redeploy it again, it works.

        Show
        grant.gochnauer Grant Gochnauer added a comment - What's strange is that if I remove the EAR and redeploy it again, it works.

          People

          • Assignee:
            juergen.hoeller Juergen Hoeller
            Reporter:
            grant.gochnauer Grant Gochnauer
            Last updater:
            Trevor Marshall
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since last comment:
              8 years, 1 week, 4 days ago