i have the 3 classes:
public abstract class Provider{
@Autowired
private ModelService modelService;
protected void foo(String name) throws Exception {
modelService.doSomething(); //line 10
}
}
@Service
public class MyProvider extends Provider {
// calling foo on the parent
foo("mayName");
}
public class MyOAuthProvider extends MyProvider {
// calling foo on the parent-->parrent
foo("mayName");
}
when i call foo from MyProvider the function work
when i call foo from MyOAuthProvider the function fail on NullPointerException because modelService is null
trace:
Exception in thread "main" java.lang.NullPointerException
at my.Provider.foo(Provider.java:10)
at my.Nain.main(Nain.java:7)
Anyone can help me to understand why this happens and how can i solve my problem