title: Trying to define my controllers as service in Symfony2 — the arguments are never passed to the constructor
body: <p>So, here is a controller I've just built:</p>
  
  <pre><code>namespace MDP\API\ImageBundle\Controller;
  use Symfony\Component\HttpFoundation\Request;
  use Symfony\Component\HttpFoundation\JsonResponse;
  use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  
  class RetrieverController {
  
      private $jsonResponse;
  
      private $request;
  
      public function __construct(JsonResponse $jsonResponse, Request $request) {
          $this-&gt;jsonResponse = $jsonResponse;
          $this-&gt;request = $request;
      }
  
      /**
       * @Route("/image/{amount}")
       * @Template("MDPAPIImageBundle:Retriever:index.json.twig")
       */
      public function retrieve($amount)
      {
      }
  }
  </code></pre>
  
  <p>I want to make this controller work as a service, to use DependencyInjection. So, here is my <code>services.xml</code> file:</p>
  
  <pre><code>&lt;?xml version="1.0" ?&gt;
  
  &lt;container xmlns="http://symfony.com/schema/dic/services"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"&gt;
  
  
      &lt;services&gt;
          &lt;service id="mdpapi_image.json_response" class="Symfony\Component\HttpFoundation\JsonResponse" /&gt;
          &lt;service id="mdpapi_image.request" class="Symfony\Component\HttpFoundation\Request" /&gt;
          &lt;service id="mdpapi_image.controller.retriever" class="MDP\API\ImageBundle\Controller\RetrieverController"&gt;
              &lt;argument type="service" id="mdpapi_image.json_response" /&gt;
              &lt;argument type="service" id="mdpapi_image.request" /&gt;
          &lt;/service&gt;
      &lt;/services&gt;
  &lt;/container&gt;
  </code></pre>
  
  <p>However, when I try to execute my controller, I always get this exception:</p>
  
  <p><strong>Catchable Fatal Error: Argument 1 passed to MDP\API\ImageBundle\Controller\RetrieverController::__construct() must be an instance of Symfony\Component\HttpFoundation\JsonResponse, none given, called in /home/steve/projects/APIs/app/cache/dev/jms_diextra/controller_injectors/MDPAPIImageBundleControllerRetrieverController.php on line 13 and defined in /home/steve/projects/ImageAPI/ImageBundle/Controller/RetrieverController.php line 13</strong> </p>
  
  <p>When I am in dev mode, I see that Symfony generate this file in the cached files...</p>
  
  <pre><code>class RetrieverController__JMSInjector
  {
      public static function inject($container) {
          $instance = new \MDP\API\ImageBundle\Controller\RetrieverController();
          return $instance;
      }
  }
  </code></pre>
  
  <p>How can I make it so that the arguments are added correctly to the controller, like specified in my <code>services.xml</code> file?</p>