title: Why @Autowired in LoginModule return null?
body: <p>I do Spring Security with JAAS .But @Autowired return null</p>
  <pre><code>    package com.example.LabOneBusinessLogic.config.Security.Jaas;
  
  import com.example.LabOneBusinessLogic.config.Security.jwt.JwtProvider;
  import com.example.LabOneBusinessLogic.entity.Users;
  import com.example.LabOneBusinessLogic.service.UserService;;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Service;
  
  import javax.security.auth.Subject;
  import javax.security.auth.callback.*;
  import javax.security.auth.login.LoginException;
  import javax.security.auth.spi.LoginModule;
  import java.util.ArrayList;
  import java.util.List;
  import java.util.Map;
  
  public class JaasLoginModule implements LoginModule
      {
          private CallbackHandler handler;
          private Subject subject;
          private  String login;
          private List&lt;String&gt; userGroups;
      
          @Autowired
          private JwtProvider jwtProvider;
      
      
          @Autowired
          private UserService userService;
          public void initialize(Subject subject, CallbackHandler callbackHandler, Map&lt;String, ?&gt; sharedState, Map&lt;String, ?&gt; options)
              {
      
                  handler = callbackHandler;
                  this.subject = subject;
              }
      
      
      
          @Override
          public boolean login() throws LoginException {
              Callback[] callbacks = new Callback[2];
              callbacks[0] = new NameCallback(&quot;username&quot;);
              callbacks[1] = new PasswordCallback(&quot;password&quot;, true);
      
              try {
      
                  handler.handle(callbacks);
                  String name = ((NameCallback) callbacks[0]).getName();
                  String password = String.valueOf(((PasswordCallback) callbacks[1]).getPassword());
                  String userLogin = jwtProvider.getLoginFromToken(password);
                  Users userEntity = userService.findByLogin(userLogin);
                  if (userEntity!=null) {
                      userGroups = new ArrayList&lt;String&gt;();
                      userGroups.add(&quot;USER&quot;);
                      return true;
                  }
              } catch (Exception e) {
                  return false;
              }
              return false;
          }
      
          @Override
          public boolean commit() throws LoginException {
      
              if (userGroups != null &amp;&amp; userGroups.size() &gt; 0) {
                  for (String groupName : userGroups) {
                      subject.getPrincipals().add(new JaasPrincipal(groupName));
                  }
              }
              return true;
          }
      
          @Override
          public boolean abort() throws LoginException {
              return false;
          }
      
          @Override
          public boolean logout() throws LoginException {
              subject.getPrincipals().clear();
              return true;
          }
      
      
      }
  </code></pre>