Announcement Announcement Module
Collapse
No announcement yet.
Circular Dependencies Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Circular Dependencies

    Hi,

    Does the order in which bean declarations appear in Spring XML count ?
    I thought it didn't, but I have a declaration X that depends (property) on Y, and Y depends on X (property, again, not constructor).

    Spring said there was a circular dependency. Then I moved the first declaration somewhere else in the file, and the problem disappeared...
    I was so astonished that I put it back to make sure moving the declaration in the file actually changes the way Spring interprets the file..

    So, can you tell more about this order dependency in the file ?

    regards,
    Sami

  • #2
    Hiya

    The order of the declarations of one's beans in one or more XML configurations (or indeed any configuration) does not matter. All metadata is parsed into an internal object representation before any beans are actually resolved. If this were not the case then the BeanPostProcessor and other such classes would not function as expected.

    Unsurprisingly, there is no unit / integration test for asserting that the order of bean definitions doesn't make a difference.

    Can you describe your XML configuration in more detail? Are you using autowiring? Are you using a hierarchy of [BeanFactory | ApplicationContext]s? Are you registering any object definitions manually (i.e. in Java code via registerBeanDefinition())?

    It is not that I don't believe you (I do), but could you (if possible) post a distilled version of your config file (and the relevant classes) that succinctly illustrates the circular dependency exception? This would help me (and others on this forum) pinpoint the issue.

    Ciao
    Rick

    Comment


    • #3
      A couple of points; you can change the order in which beans are instantiated by setting the "depends-on" attribute in the bean element.

      Second point; you are almost certainly setting singleton="false" which is creating a new bean every time, thus beanA wants BeanB, beanB needs a new BeanA which needs a new BeanB etc. If you can, change them to singletons (remove the singleton="false", true is the default).

      Third point; always post the xml in question and any stack traces

      Comment


      • #4
        Hiya

        The order of the declarations of one's beans in one or more XML configurations (or indeed any configuration) does not matter. All metadata is parsed into an internal object representation before any beans are actually resolved. If this were not the case then the BeanPostProcessor and other such classes would not function as expected.
        OK, so I guess this is a bug.. I'm going to try to describe my scenario. I can't post the whole XML document because it's way too big, so you wouldn't understand what's going on. Let's try to sum up..


        Can you describe your XML configuration in more detail? Are you using autowiring?
        No, I'm using plan ref bean=".." everywhere.


        Are you using a hierarchy of [BeanFactory | ApplicationContext]s?
        No, just a plan ApplicationContext splited into two files.

        Are you registering any object definitions manually (i.e. in Java code via registerBeanDefinition())?
        No

        It is not that I don't believe you (I do), but could you (if possible) post a distilled version of your config file (and the relevant classes) that succinctly illustrates the circular dependency exception? This would help me (and others on this forum) pinpoint the issue.
        OK, so first, here's the exact error message.

        Code:
        Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'navigationPanelBuilder' defined in class path resource [applicationContextDisplay.xml]: Can't resolve reference to bean 'rotatingBoxesBranchGroup' while setting property 'descriptionLister'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rotatingBoxesBranchGroup' defined in class path resource [applicationContextDisplay.xml]: Can't resolve reference to bean 'mapTexturableBox' while setting property 'constructor argument with index 2[0]'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mapTexturableBox' defined in class path resource [applicationContextDisplay.xml]: Can't resolve reference to bean 'weatherMapsBuilder' while setting property 'sceneInformation'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'weatherMapsBuilder' defined in class path resource [applicationContextDisplay.xml]: Can't resolve reference to bean 'rotatingBoxesBranchGroup' while setting property 'objectGroup'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'rotatingBoxesBranchGroup': Requested bean is currently in creation (circular reference when autowiring constructor?)
        org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rotatingBoxesBranchGroup' defined in class path resource [applicationContextDisplay.xml]: Can't resolve reference to bean 'mapTexturableBox' while setting property 'constructor argument with index 2[0]'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mapTexturableBox' defined in class path resource [applicationContextDisplay.xml]: Can't resolve reference to bean 'weatherMapsBuilder' while setting property 'sceneInformation'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'weatherMapsBuilder' defined in class path resource [applicationContextDisplay.xml]: Can't resolve reference to bean 'rotatingBoxesBranchGroup' while setting property 'objectGroup'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'rotatingBoxesBranchGroup': Requested bean is currently in creation (circular reference when autowiring constructor?)
        org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mapTexturableBox' defined in class path resource [applicationContextDisplay.xml]: Can't resolve reference to bean 'weatherMapsBuilder' while setting property 'sceneInformation'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'weatherMapsBuilder' defined in class path resource [applicationContextDisplay.xml]: Can't resolve reference to bean 'rotatingBoxesBranchGroup' while setting property 'objectGroup'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'rotatingBoxesBranchGroup': Requested bean is currently in creation (circular reference when autowiring constructor?)
        org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'weatherMapsBuilder' defined in class path resource [applicationContextDisplay.xml]: Can't resolve reference to bean 'rotatingBoxesBranchGroup' while setting property 'objectGroup'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'rotatingBoxesBranchGroup': Requested bean is currently in creation (circular reference when autowiring constructor?)
        org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'rotatingBoxesBranchGroup': Requested bean is currently in creation (circular reference when autowiring constructor?)
        	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:182)
        	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:146)
        	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:176)
        	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:105)
        	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:891)
        	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:707)
        	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:316)
        	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:222)
        	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:146)
        	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:176)
        	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:105)
        	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:891)
        	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:707)
        	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:316)
        	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:222)
        	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:146)
        	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:176)
        	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:105)
        	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:193)
        	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
        	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveConstructorArguments(AbstractAutowireCapableBeanFactory.java:591)
        	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:497)
        	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:298)
        	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:222)
        	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:146)
        	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:176)
        	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:105)
        	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:891)
        	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:707)
        	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:316)
        	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:222)
        	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:146)
        	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:277)
        	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:310)
        	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>&#40;ClassPathXmlApplicationContext.java&#58;80&#41;
        	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>&#40;ClassPathXmlApplicationContext.java&#58;65&#41;
        	at weather.main.Main.main&#40;Main.java&#58;18&#41;
        So, let's first consider 2 beans. The following configuration leads to the previous exception
        Code:
        <bean id="navigationPanelBuilder" 
        		class="weather.ui.builder.NavigationPanelBuilder" 
        		singleton="true">
        		<property name="descriptionLister">
        	  		<ref bean="rotatingBoxesBranchGroup"/>
        		</property>
        		<property name="sceneInformation">
        	  		<ref bean="weatherMapsBuilder"/>
        		</property>
        	</bean>
        
        	<bean id="weatherMapsBuilder" 
        		class="weather.ui.builder.WeatherMapsBuilder"
        		singleton="true">
        		<property name="objectGroup">
        	  		<ref bean="rotatingBoxesBranchGroup"/>
        		</property>
        		<property name="interpolatorGroup">
        	  		<ref bean="interpolatorsBranchGroup"/>
        		</property>
        		<property name="pickManager">
        	  		<ref bean="pickManager"/>
        		</property>
        	</bean>
        while the following one works nicely :
        Code:
        	<bean id="weatherMapsBuilder" 
        		class="weather.ui.builder.WeatherMapsBuilder"
        		singleton="true">
        		<property name="objectGroup">
        	  		<ref bean="rotatingBoxesBranchGroup"/>
        		</property>
        		<property name="interpolatorGroup">
        	  		<ref bean="interpolatorsBranchGroup"/>
        		</property>
        		<property name="pickManager">
        	  		<ref bean="pickManager"/>
        		</property>
        	</bean>
        
        <bean id="navigationPanelBuilder" 
        		class="weather.ui.builder.NavigationPanelBuilder" 
        		singleton="true">
        		<property name="descriptionLister">
        	  		<ref bean="rotatingBoxesBranchGroup"/>
        		</property>
        		<property name="sceneInformation">
        	  		<ref bean="weatherMapsBuilder"/>
        		</property>
        	</bean>
        And Here are the other beans definitions these two beans depend on :
        Code:
        	<bean id="rotatingBoxesBranchGroup"
        		class="weather.ui.maps3d.RotatingBoxesBranchGroup"
        		singleton="true">
        		<constructor-arg index="0">
        			<ref bean="interpolatorsBranchGroup"/>
        		</constructor-arg>
        		<constructor-arg index="1">
        			<ref local="notificationManager" />
        		</constructor-arg>
        		<constructor-arg index="2">
        	  		<list>
        		      <ref bean="mapTexturableBox"/>
        		      <ref bean="chartTexturableBox"/>
        		      <ref bean="secondChartTexturableBox"/>
        		      <ref bean="anotherChartTexturableBox"/>
        		      <ref bean="anotherSecondChartTexturableBox"/>
        		    </list>
        		</constructor-arg>
        		<property name="animationsRunningState">
        	  		<ref bean="animationsRunningState"/>
        		</property>
        		<property name="objectFocusedState">
        	  		<ref bean="objectFocusedState"/>
        		</property>
        		<property name="currentState">
        	  		<ref bean="animationsRunningState"/>
        		</property>
        	</bean>
        
        
        	<bean id="interpolatorsBranchGroup"
        		class="weather.ui.maps3d.InterpolatorsGroup"
        		singleton="true">
        		<property name="sceneInformation">
        	  		<ref bean="weatherMapsBuilder"/>
        		</property>
        	</bean>
        
        	<bean id="pickManager" 
        		class="weather.ui.maps3d.PickManager"
        		singleton="true">
        		<property name="sceneInformation">
        	  		<ref bean="weatherMapsBuilder"/>
        		</property>
        	</bean>
        Oh, BTW, The problem appeared when I added the
        Code:
        		<property name="descriptionLister">
        	  		<ref bean="rotatingBoxesBranchGroup"/>
        		</property>
        to the navigationPanelBuilder bean.

        the descriptionLister property is of type IDesriptionLister (implemented by rotatingBoxesBranchGroup), and weatherMapsbuilder.objectGroup property is of the type of RotatingBranchGroup.

        I hope it gives you enough information.. Don't hesitate to ask me for more details on a specific bean/class.

        Regards,
        Sami Dalouche[/quote]

        Comment


        • #5
          Hi,

          it's me again.

          I refactored my application a little bit, because of some design issues. It looks like that either I'm doing something particularly wrong, or I'm particularly talented to make bugs appear.

          So, Here's another example of this circular dependency thing :

          Code:
          Exception in thread "main" org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'navigationPanel' defined in class path resource &#91;applicationContextDisplay.xml&#93;&#58; Can't resolve reference to bean 'rotatingBoxesBranchGroup' while setting property 'constructor argument with index 0'; nested exception is org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'rotatingBoxesBranchGroup' defined in class path resource &#91;applicationContextDisplay.xml&#93;&#58; Can't resolve reference to bean 'mapTexturableBox' while setting property 'constructor argument with index 2&#91;0&#93;'; nested exception is org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'mapTexturableBox' defined in class path resource &#91;applicationContextDisplay.xml&#93;&#58; Can't resolve reference to bean 'panel3D' while setting property 'sceneInformation'; nested exception is org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'panel3D' defined in class path resource &#91;applicationContextDisplay.xml&#93;&#58; Can't resolve reference to bean 'rotatingBoxesBranchGroup' while setting property 'objectGroup'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException&#58; Error creating bean with name 'rotatingBoxesBranchGroup'&#58; Requested bean is currently in creation &#40;circular reference when autowiring constructor?&#41;
          org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'rotatingBoxesBranchGroup' defined in class path resource &#91;applicationContextDisplay.xml&#93;&#58; Can't resolve reference to bean 'mapTexturableBox' while setting property 'constructor argument with index 2&#91;0&#93;'; nested exception is org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'mapTexturableBox' defined in class path resource &#91;applicationContextDisplay.xml&#93;&#58; Can't resolve reference to bean 'panel3D' while setting property 'sceneInformation'; nested exception is org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'panel3D' defined in class path resource &#91;applicationContextDisplay.xml&#93;&#58; Can't resolve reference to bean 'rotatingBoxesBranchGroup' while setting property 'objectGroup'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException&#58; Error creating bean with name 'rotatingBoxesBranchGroup'&#58; Requested bean is currently in creation &#40;circular reference when autowiring constructor?&#41;
          org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'mapTexturableBox' defined in class path resource &#91;applicationContextDisplay.xml&#93;&#58; Can't resolve reference to bean 'panel3D' while setting property 'sceneInformation'; nested exception is org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'panel3D' defined in class path resource &#91;applicationContextDisplay.xml&#93;&#58; Can't resolve reference to bean 'rotatingBoxesBranchGroup' while setting property 'objectGroup'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException&#58; Error creating bean with name 'rotatingBoxesBranchGroup'&#58; Requested bean is currently in creation &#40;circular reference when autowiring constructor?&#41;
          org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'panel3D' defined in class path resource &#91;applicationContextDisplay.xml&#93;&#58; Can't resolve reference to bean 'rotatingBoxesBranchGroup' while setting property 'objectGroup'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException&#58; Error creating bean with name 'rotatingBoxesBranchGroup'&#58; Requested bean is currently in creation &#40;circular reference when autowiring constructor?&#41;
          org.springframework.beans.factory.BeanCurrentlyInCreationException&#58; Error creating bean with name 'rotatingBoxesBranchGroup'&#58; Requested bean is currently in creation &#40;circular reference when autowiring constructor?&#41;
          	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;182&#41;
          	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;146&#41;
          	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference&#40;BeanDefinitionValueResolver.java&#58;176&#41;
          	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary&#40;BeanDefinitionValueResolver.java&#58;105&#41;
          	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues&#40;AbstractAutowireCapableBeanFactory.java&#58;891&#41;
          	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean&#40;AbstractAutowireCapableBeanFactory.java&#58;707&#41;
          	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;316&#41;
          	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;222&#41;
          	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;146&#41;
          	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference&#40;BeanDefinitionValueResolver.java&#58;176&#41;
          	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary&#40;BeanDefinitionValueResolver.java&#58;105&#41;
          	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues&#40;AbstractAutowireCapableBeanFactory.java&#58;891&#41;
          	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean&#40;AbstractAutowireCapableBeanFactory.java&#58;707&#41;
          	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;316&#41;
          	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;222&#41;
          	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;146&#41;
          	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference&#40;BeanDefinitionValueResolver.java&#58;176&#41;
          	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary&#40;BeanDefinitionValueResolver.java&#58;105&#41;
          	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList&#40;BeanDefinitionValueResolver.java&#58;193&#41;
          	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary&#40;BeanDefinitionValueResolver.java&#58;109&#41;
          	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveConstructorArguments&#40;AbstractAutowireCapableBeanFactory.java&#58;591&#41;
          	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor&#40;AbstractAutowireCapableBeanFactory.java&#58;497&#41;
          	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;298&#41;
          	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;222&#41;
          	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;146&#41;
          	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference&#40;BeanDefinitionValueResolver.java&#58;176&#41;
          	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary&#40;BeanDefinitionValueResolver.java&#58;105&#41;
          	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveConstructorArguments&#40;AbstractAutowireCapableBeanFactory.java&#58;591&#41;
          	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor&#40;AbstractAutowireCapableBeanFactory.java&#58;497&#41;
          	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;298&#41;
          	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;222&#41;
          	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;146&#41;
          	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons&#40;DefaultListableBeanFactory.java&#58;277&#41;
          	at org.springframework.context.support.AbstractApplicationContext.refresh&#40;AbstractApplicationContext.java&#58;310&#41;
          	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>&#40;ClassPathXmlApplicationContext.java&#58;80&#41;
          	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>&#40;ClassPathXmlApplicationContext.java&#58;65&#41;
          	at weather.main.Main.main&#40;Main.java&#58;18&#41;
          with the following beans described in this order :
          Code:
          	<bean id="navigationPanel" 
          		class="weather.ui.panels.NavigationPanel" 
          		singleton="true">
          		<constructor-arg index="0">
          			<ref bean="rotatingBoxesBranchGroup"/>
          		</constructor-arg>
          		<property name="sceneInformation">
          	  		<ref bean="panel3D"/>
          		</property>
          	</bean>
          
          	<bean id="panel3D" 
          		class="weather.ui.panels.Weather3dPanel" 
          		singleton="true"
          		init-method="init">
          
          		<property name="interpolatorGroup">
          	  		<ref bean="interpolatorsBranchGroup"/>
          		</property>
          		<property name="pickManager">
          	  		<ref bean="pickManager"/>
          		</property>
          
          		<property name="objectGroup">
          	  		<ref bean="rotatingBoxesBranchGroup"/>
          		</property>
          	</bean>
          However, everything runs fine with :

          Code:
          	<bean id="panel3D" 
          		class="weather.ui.panels.Weather3dPanel" 
          		singleton="true"
          		init-method="init">
          
          		<property name="interpolatorGroup">
          	  		<ref bean="interpolatorsBranchGroup"/>
          		</property>
          		<property name="pickManager">
          	  		<ref bean="pickManager"/>
          		</property>
          
          		<property name="objectGroup">
          	  		<ref bean="rotatingBoxesBranchGroup"/>
          		</property>
          	</bean>
          few Remarks :
          panel3D implements the ISceneInformation interface used for properties called sceneInformation.
          rotatingBoxesBranchGroup constructor-depends on mapText... which property-depends on panel3d through the ISceneInformation interface.

          Code:
          	<bean id="rotatingBoxesBranchGroup"
          		class="weather.ui.maps3d.RotatingBoxesBranchGroup"
          		singleton="true">
          		<constructor-arg index="0">
          			<ref bean="interpolatorsBranchGroup"/>
          		</constructor-arg>
          		<constructor-arg index="1">
          			<ref local="notificationManager" />
          		</constructor-arg>
          		<constructor-arg index="2">
          	  		<list>
          		      <ref bean="mapTexturableBox"/>
          		      <ref bean="chartTexturableBox"/>
          		      <ref bean="secondChartTexturableBox"/>
          		      <ref bean="anotherChartTexturableBox"/>
          		      <ref bean="anotherSecondChartTexturableBox"/>
          		    </list>
          		</constructor-arg>
          		<property name="animationsRunningState">
          	  		<ref bean="animationsRunningState"/>
          		</property>
          		<property name="objectFocusedState">
          	  		<ref bean="objectFocusedState"/>
          		</property>
          		<property name="currentState">
          	  		<ref bean="animationsRunningState"/>
          		</property>
          	</bean>
          
          	<bean id="abstractTexturableBox"
          		class="weather.ui.maps3d.TexturableBox"
          		abstract="true">
          		<constructor-arg index="0">
          			<value>0.5</value>
          		</constructor-arg>
          		<constructor-arg index="1">
          			<value>0.5</value>
          		</constructor-arg>
          		<constructor-arg index="2">
          			<value>0.5</value>
          		</constructor-arg>
          		<constructor-arg index="3">
          			<ref local="boxAppearanceTemplate" />
          		</constructor-arg>
          
          		<property name="sceneInformation">
          	  		<ref bean="panel3D"/>
          		</property>
          
          	</bean>
          
          
          	<bean id="mapTexturableBox"
          		parent="abstractTexturableBox"
          		singleton="true"
          		abstract="false">
          		<property name="description">
          		<value>Canada&#58; Maps</value>
          		</property>
              </bean>
          I hope you can see what's going on....

          BTW, I'm using init-method on panel3D to initialize all my GUI once the properties are set. without this, I had to constructor-depend on the properties, which lead to real circular dependencies. What's your advice concerning init-method ? should it be used as a trick to remove circular depends ? (which means, a hack), or a nice design shouldn't have to deal with this ?

          Comment

          Working...
          X