How to solve Spring IoC during Inheritance
Hi,
I have a classs SpringManager, it extends another class BaseManger. I have another class Basemanger.
Entries in the Spring context file are :
<bean id="SpringManager" class="com.test.springweb.bus.SpringManager">
</bean>
<bean id="BaseSeason" class="com.test.springweb.bus.BaseSeason">
<property name="test" ref="Test"></property>
</bean>
SpringManager has a method check()
public String check()
{
test(); // calls BaseManager's method
}
BaseManager has a mehtod test()
public void test()
{
test.testmethod(); // calls testmethod() of Test class
}
When run the application and call SpringManager's check method, am getting
Null pointer exception in test.testmethod() line.
The corresponding setter methods are proper.
I guess it is may be cos SpringManager does nto have a refernce to its base class.
Doesnt Spring creates an object of its base also, thus creating the object of its refrence?
Can you anyone help regarding this ? Thanks in advance.
How to solve Spring IoC during Inheritance
Hi
I have the entry for Test bean also i nthe same context file.
<bean id="Test" class="com.test.springweb.bus.Test"></bean>
Also have the setter method for Test in BaseSeason.
public class BaseSeason
{
Test test;
public void test()
{
try
{
test.testmethod();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public void setTest(Test test)
{
this.test = test;
}
}
When i run the application, it actually calls the SpringManager class check ()method. From there its base class method test() is called.
Please help me regarding this.
Also i want to know when exactly the objects are created for the class, when the context files are loaded or when the class is called at runtime ?