Issue with injecting datamanager in service class

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?

Hi @renuka.venugopal01 ,

can you please share sample project , that has the issue so we can help

Thanks

Hi,
Please find attached the sample project.
Thanks,
Renukasample.zip (316.1 KB)

Hi,
Please refer to the DMServiceBean class in the sample project.
Regards,
Renuka

Hello @renuka.venugopal01

Please note that you will not be able to use DataManager to initialize service fields, because all injections are done after full object initialization

Hi @renuka.venugopal01 ,

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

sample-data-manager.7z (53.3 KB)