Dave Tolls wrote:I'm getting a little confused here.
Can you show the call to importDoc that causes the NullPointerException?
Can you also show where in that class (the one calling importDoc) that the instance of Good it uses comes from?
Dave Tolls wrote:
Mohammed Sardar. wrote:
We call this Good from other class by reflection but the Good is also initiated at the time of component scanning as a base package. Thanks
How do you get it by reflection?
I'm not sure that Spring would be involved in that, and so you would not be getting the Spring Bean, but something else entirely, something which would not have had anything injected into it.
Dave Tolls wrote:
Where is instance of Good used that appears in the NullPointerException stacktrace?
Where is that instance instantiated/injected?
Can you show that code?
Al Hobbs wrote:You need to make sure you are scanning the right packages. Also make sure your rxxxblahhelper class is annotated with @component. Since its not a webapp you need to make sure the spring container is started from main
container gives back the bean. If try two to autowire no luck with null. I'm trying to get the bean autowired and get the bean required all over the application, instead implementing context everywhere and using getBean() method.
Nice to hear you enjoy the class names I named, because you are good as they . Yes, There're classes exist. And they are available from ApplicationContext but unable to do Auto wiring since it throws NPE.
Al Hobbs wrote:So youre getting a null when its trying to inject rxxxblahhelper? Does that class even exist? Also great class names . Class good and it extends class good11. ;p
I agree. In this situation, how can we utilize spring feature
arent supposed to have injection code in the class. that defeats the purpose of doing dependency injection in the first place