Results 1 to 3 of 3

Thread: ContextSingletonBeanFactoryLocator problem

  1. #1
    Join Date
    Mar 2005
    Posts
    1

    Default ContextSingletonBeanFactoryLocator problem

    Hi, all:

    I am trying to create a static class, which would return ApplicationContext. I am using pieces of code from this forum, but I am getting an exception.

    The code is:
    Code:
        public static ApplicationContext getApplicationContext(String applicationName) { 
          if( applicationContext == null ) { 
            synchronized( lock ) { 
              if( applicationContext == null ) { 
                BeanFactoryLocator bfl = ContextSingletonBeanFactoryLocator.getInstance(); 
                BeanFactoryReference bf = bfl.useBeanFactory(applicationName);
                applicationContext = (ApplicationContext) bf.getFactory();
              } 
            } 
          } 
          return applicationContext; 
        }
    beanRefContext is:
    Code:
     <beans>
    
       <bean id="test.this.thing" lazy-init="true"
             class="org.springframework.context.support.ClassPathXmlApplicationContext">
         <constructor-arg>
           <list>
             <value>/WEB-INF/applicationContextWeb.xml</value>
             <value>/com/greenview/fpi/util/applicationContextUtil.xml</value>
           </list>
         </constructor-arg>
       </bean>
    ...
    Exception is:
    Code:
    org.springframework.beans.FatalBeanException&#58; Returned bean is not BeanFactory or its subclass. lookup ID &#91;test.this.thing&#93;, factory key &#91;test.this.thing&#93;, from group with resource name &#91;classpath*&#58;beanRefContext.xml&#93;. Returned object class is &#91;org.springframework.context.support.ClassPathXmlApplicationContext&#93;
    	at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory&#40;SingletonBeanFactoryLocator.java&#58;408&#41;
    I would greatly appreciate any help.

    Thanks.

  2. #2
    Join Date
    Nov 2004
    Location
    Ottawa, Canada
    Posts
    7

    Default Re: ContextSingletonBeanFactoryLocator problem

    Code:
     <beans>
    
       <bean id="test.this.thing" lazy-init="true"
             class="org.springframework.context.support.ClassPathXmlApplicationContext">
         <constructor-arg>
           <list>
             <value>/WEB-INF/applicationContextWeb.xml</value>
             <value>/com/greenview/fpi/util/applicationContextUtil.xml</value>
           </list>
         </constructor-arg>
       </bean>
    ...
    The /WEB-INF/applicationContextWeb.xml does not look like part of the
    classpath. Try to move applicationContextWeb.xml under WEB-INF/classes and load without /WEB-INF/ prefix.

    Good luck

  3. #3
    Join Date
    Apr 2006
    Posts
    4

    Smile beanRefContext found but its enclosing bean definitons xml not found

    Our beanRefContext is as follows:
    <beans>
    <bean id="springBeanContext" lazy-init="true"
    class="org.springframework.context.support.ClassPa thXmlApplicationContext">
    <constructor-arg>
    <list>
    <value>appEjbBusinessObjects.xml</value>
    <value>appManagers.xml</value>
    </list>
    </constructor-arg>
    </bean>
    </beans>

    We use ContextSingletonBeanFactoryLocator. At deployment time, the beanRefContext.xml is loaded but it spring complained that it could not find one of the enclosed bean definitions xml, such as appManagers.xml. This xml is in a root of a different jar. I set the lazy-init="true". Why spring tries to load all bean xmls at deployment time. Because of this, we ended up putting all bean xmls into one big xml file, which is not desirable. We was expecting to have a bean xml for each our components.

    Please help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •