Bean definition is not properly being read
Hello All,
I'm facing this weird problem and I would try to post the problem as clearly as possible.
We have a project, which deals with Webservice calls. Let us call this ProjectA.
Under ProjectA,
We have several classes defined, but particularly we are interested in a class say "BaseClass" which extends "WebServiceGatewaySupport". This class does nothing specific except having some getters and setters for some properties. We have another main class, "ChildClass" that extends "BaseClass" and also builds some context based on the properties defined in "BaseClass".
Now we have these beans defined in our bean definition file as below
Code:
<bean name="baseDelegate" abstract="true"
class="com.domain.webservice.BaseClass">
<property name="invokerId" value="${context.invokerid}" />
<property name="activitySourceId" value="${context.activitysourceid}" />
</bean>
<!-- GetAlertMessage dependency -->
<bean name="getChildDelegate"
class="com.domain.delegate.ChildClass"
parent="baseDelegate">
</bean>
For brevity I have removed unnecessary information. The BaseClass has several properties which I have not displayed for brevity, but the point here is all these properties are read from external properties file and we have the following setup for reading the properties file
Code:
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>
<bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor" />
<context:property-placeholder location="classpath:N3.properties"/>
We also have an annotation for the ChildClass as
@Component("getChildDelegate")
With this setup, everything is working great. Unit tests ran fine. We loaded the context using FileSystemXmlApplicationContext. Properties are being read great from properties file etc.
Now we need to integrate this project with another web application. Similar to ProjectA, there were several projects coded on same lines and all these projects are intergrated in one big web app.
Now, when we have the similar bean definitions as quoted above in web app, the properties in BaseClass are not read properly from the external properties file. Where as all the other projects which are exactly on same lines works great.
After lot of trials, we could not find any convincing reason for the problem, except that we changed the bean definition from getChildDelegate to getChild.. and voila, it works great now... I did not understand why it should fail when it is being referred as getChildDelegate in the bean definition file and where the bean is retrieved as "getChildDelegate" and why should it work when we change this to "getChild".
Another element of surprise for me here, in the original projectA, the bean definition is still referring to "getChildDelegate"....
Can anybody advise me on this peculiar behavior of Spring and let me know, if any additional information is needed.
Though things are working fine now, I'm very skeptical on the solution we applied and really want to understand what was wrong.