title: "Cannot import resource" exception randomly after deploying Symfony2 application
body: <p>After deploying my Symfony application on a server I remove the cache using command:</p>
  
  <pre><code>sudo rm -rf app/cache
  </code></pre>
  
  <p>Usually everything works fine but from time to time I got an exception with message:</p>
  
  <pre><code>Cannot import resource
  "/var/projectsssssss/src/Project/UserPanelBundle/Controller" from 
  "/var/projectsssssss/src/Project/UserPanelBundle/Resources/config/routing.yml".
  </code></pre>
  
  <p>Then, I remove cache again and it's working until random next deploy. I use annotation for Routes. Exception is thrown when using Controller <code>generateUrl</code> method here is a stack trace:</p>
  
  <pre><code>#0 /var/project/vendor/symfony/symfony/src/Symfony/Component/Routing/Loader/YamlFileLoader.php(75): Symfony\\Component\\Config\\Loader\\FileLoader-&gt;import('@UserPanelBundl...', 'annotation', false, '/var/projectsss...')
  #1 /var/project/vendor/symfony/symfony/src/Symfony/Component/Config/Loader/FileLoader.php(75): Symfony\\Component\\Routing\\Loader\\YamlFileLoader-&gt;load('/var/projectsss...', NULL)
  #2 /var/project/vendor/symfony/symfony/src/Symfony/Component/Routing/Loader/YamlFileLoader.php(75): Symfony\\Component\\Config\\Loader\\FileLoader-&gt;import('@UserPanelBundl...', NULL, false, '/var/projectsss...')
  #3 /var/project/vendor/symfony/symfony/src/Symfony/Component/Config/Loader/DelegatingLoader.php(52): Symfony\\Component\\Routing\\Loader\\YamlFileLoader-&gt;load('/var/projectsss...', NULL)
  #4 /var/project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php(57): Symfony\\Component\\Config\\Loader\\DelegatingLoader-&gt;load('/var/projectsss...', NULL)
  #5 /var/project/app/cache/main/classes.php(1742): Symfony\\Bundle\\FrameworkBundle\\Routing\\DelegatingLoader-&gt;load('/var/projectsss...', NULL)
  #6 /var/project/app/cache/main/classes.php(1451): Symfony\\Bundle\\FrameworkBundle\\Routing\\Router-&gt;getRouteCollection()
  #7 /var/project/app/cache/main/classes.php(1400): Symfony\\Component\\Routing\\Router-&gt;getGenerator()
  #8 /var/project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php(45): Symfony\\Component\\Routing\\Router-&gt;generate('userpanel_apps', Array, false)
  #9 /var/project/src/Project/UserPanelBundle/Controller/AppsController.php(26): Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller-&gt;generateUrl('userpanel_apps', Array)
  #10 [internal function]: Project\\UserPanelBundle\\Controller\\AppsController-&gt;indexAction()
  #11 /var/project/app/bootstrap.php.cache(1426): call_user_func_array(Array, Array)
  #12 /var/project/app/bootstrap.php.cache(1390): Symfony\\Component\\HttpKernel\\HttpKernel-&gt;handleRaw(Object(Symfony\\Component\\HttpFoundation\\Request), 1)
  #13 /var/project/app/bootstrap.php.cache(1566): Symfony\\Component\\HttpKernel\\HttpKernel-&gt;handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)
  #14 /var/project/app/bootstrap.php.cache(617): Symfony\\Bundle\\FrameworkBundle\\HttpKernel-&gt;handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)
  #15 /var/project/web/app.php(28): Symfony\\Component\\HttpKernel\\Kernel-&gt;handle(Object(Symfony\\Component\\HttpFoundation\\Request))
  #16 {main}
  </code></pre>
  
  <p>I suppose there is some problem with cache generation but how to avoid it?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>My <code>routing.yml</code>:</p>
  
  <pre><code>default:
      resource: "@UserPanelBundle/Controller"
      type:     annotation
  </code></pre>