Hi,
I have a bean class which implements a service. I am facing issue with injecting datamanager in the bean class. Below is the code snippet.
@Service(SourceSchemaWizardService.NAME)
public class SourceSchemaWizardServiceBean implements SourceSchemaWizardService {
@Inject
private DataManager dataManager;
......
ETLDataSource ds= dataManager.load(ETLDataSource.class);
}
When I call dataManager.load(), i am getting NullPointerException. The dataManager is not getting injected in the bean and is null. I even tried annotating the bean class using @Component instead of @Service but still it is not working.
Could you please help?
Please note that you will not be able to use DataManager to initialize service fields, because all injections are done after full object initialization
As mentioned from @tsarev , you can’t use datamanager before Bean is initialized ,
But as per my understanding , you are calling it inside function to load data , i passed through your shared sample but i think you attached it with missing module , cause it has compilation error
I just make another sample for you for handling data-manager
you can see it contains book entity which inside its aftershowevent calling to service call which is using DataManger to load all books and print them through log
Also you can refer to DataManager for further explanation
attached is running application just open inside Intellej and investigate the code and you will find running sampler