title: Java second inheritance Returning null values
body: <p>i have the 3 classes:</p>
  
  <pre><code> 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--&gt;parrent
         foo("mayName");
   }
  </code></pre>
  
  <ul>
  <li><p>when i call foo from MyProvider the function work</p></li>
  <li><p>when i call foo from MyOAuthProvider the function fail on NullPointerException because modelService is null</p></li>
  </ul>
  
  <p>trace:</p>
  
  <pre><code>Exception in thread "main" java.lang.NullPointerException
      at my.Provider.foo(Provider.java:10)
      at my.Nain.main(Nain.java:7)
  </code></pre>
  
  <p>Anyone can help me to understand why this happens and how can i solve my problem</p>