title: Call to a member function get() on null for FOSuserBundle
body: <p>I am trying to do a redirect to the registration page, if a username does not exists in the user tables. I have done all the configurations needed and I have created the handler that looks like:</p>
  
  <pre><code>namespace UserBundle\Redirection;
  
  use Symfony\Component\DependencyInjection\ContainerInterface;
  use Symfony\Component\HttpFoundation\RedirectResponse;
  use Symfony\Component\HttpFoundation\Request;
  use Symfony\Component\HttpFoundation\Response;
  use Symfony\Component\Routing\RouterInterface;
  use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  use Symfony\Component\Security\Core\Exception\AuthenticationException;
  use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
  
  class AfterLoginFailureRedirection implements AuthenticationFailureHandlerInterface
  {
      /**
       * @var \Symfony\Component\Routing\RouterInterface
       */
      private $router;
  
      /**
       * @var \Symfony\Component\DependencyInjection\ContainerInterface
       */
      private $container;
  
      /**
       * AfterLoginFailureRedirection constructor.
       * @param RouterInterface $router
       * @param ContainerInterface $container
       */
      public function __construct(RouterInterface $router, ContainerInterface $container)
      {
          $this-&gt;router = $router;
      }
  
      /**
       * @param Request $request
       * @param AuthenticationException $token
       * @return RedirectResponse
       */
      public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
      {
          //$request = $this-&gt;container-&gt;get('request');
          $token=$exception-&gt;getToken();
          $username=$token-&gt;getUsername();
          //$username = $request-&gt;request-&gt;get('email');
          $user = $this-&gt;container-&gt;get('fos_user.user_manager')-&gt;findUserByUsername($username);
  
          if(!$user-&gt;isUser()) {
              $url=$this-&gt;container-&gt;get('router')-&gt;generate('fos_user_registration_register');
              return new RedirectResponse($url);
          }
      }
  }
  </code></pre>
  
  <p>For this part of the code I am getting the error:</p>
  
  <pre><code>$user = $this-&gt;container-&gt;get('fos_user.user_manager')-&gt;findUserByUsername($username);
  </code></pre>
  
  <p>Why is this happening?</p>
  
  <p>Edit:
  I initialized correcly constructor.
  I inserted the code: else { $url=$this->container->get('router')->generate('fos_user_sec‌​urity_login'); return new RedirectResponse($url); } but it just redirects me without the login errors</p>