title: Doctrine not sure if entity is valid, doctrine:mapping:info contradicts triggered exception
body: <p>Before starting, the usual disclaimer : I am aware of dozens of questions here on SE from people encountering identical-looking problems, I have browsed them and unless I missed something,  the combination of all the fixes proposed does not solve my particular problem. </p>
  
  <p>In particular : </p>
  
  <ul>
  <li>This <a href="https://stackoverflow.com/questions/14662535/not-a-valid-entity-or-mapped-super-class">question</a> is about duplicated
  and inherited entities, which I don't have.</li>
  <li>This <a href="https://stackoverflow.com/questions/19144603/doctrine-class-is-not-a-valid-entity-or-mapped-super-class">answer</a> is about
  invalid annotation format (missing asterisks), which I don't have in my entity definition (see file content below).</li>
  <li>In this <a href="https://stackoverflow.com/questions/17765591/symfony-doctrine-class-is-not-a-valid-entity-or-mapped-super-class">question</a>, the problem
  comes from a <code>@todo</code> somewhere, which I don't use</li>
  <li>In this <a href="https://stackoverflow.com/questions/14986080/symfony2-is-not-a-valid-entity-or-mapped-super-class">question</a>, the problem
  comes from using eAccelerator which I'm not using at this point</li>
  </ul>
  
  <p>I get the following error message in Symfony :</p>
  
  <pre><code>Doctrine\ORM\Mapping\MappingException: Class "AppBundle\Entity\User" is not a valid entity or mapped super class.
  </code></pre>
  
  <p>Yet, other commands tell me everything is fine :</p>
  
  <pre><code>$ php bin/console doctrine:mapping:info
  Found 6 mapped entities:
  [OK]   AppBundle\Entity\Category
  [OK]   AppBundle\Entity\Comment
  [OK]   AppBundle\Entity\Post
  [OK]   AppBundle\Entity\Section
  [OK]   AppBundle\Entity\User
  [OK]   AppBundle\Entity\World
  </code></pre>
  
  <p>I also tried </p>
  
  <pre><code>try {
      $entityManager-&gt;getConnection()-&gt;connect();
  } catch (\Exception $e) {
      echo 'Connection failed !';
  }
  </code></pre>
  
  <p>in my code to see if the connection worked. I also tried "registering noop annotation autoloader" as 
  suggested in this <a href="https://stackoverflow.com/questions/15099060/doctrine2-class-is-not-a-valid-entity-or-mapped-super-class">SO answer</a>
  the content of my test file below reflects this ;</p>
  
  <pre><code>&lt;?php
  
  error_reporting(E_ALL|E_STRICT);  
  
  require 'app/autoload.php';
  
  xdebug_break();
  
  
  
  use AppBundle\Entity;
  use Doctrine\ORM\Tools\Setup;
  use Doctrine\ORM\EntityManager;
  use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
  use Doctrine\Common\Annotations\AnnotationReader;
  use Doctrine\Common\Annotations\AnnotationRegistry;
  
  
  
  $paths = array("src/AppBundle/Entity");
  $isDevMode = true;
  
  // the connection configuration
  $dbParams = array(
      'driver'   =&gt; 'pdo_mysql',
      'user'     =&gt; 'root',
      'password' =&gt; 'root',
      'dbname'   =&gt; 'asharis_database'
  );
  
  
  
  $config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
  
  $driver = new AnnotationDriver(new AnnotationReader(), $paths);
  // registering noop annotation autoloader - allow all annotations by default
  AnnotationRegistry::registerLoader('class_exists');
  $config-&gt;setMetadataDriverImpl($driver);
  
  
  $entityManager = EntityManager::create($dbParams, $config);
  
  try {
      $entityManager-&gt;getConnection()-&gt;connect();
  } catch (\Exception $e) {
      echo 'Connection failed !';
  }
  
  
  $users=array();
  $post=array();
  for($u=1;$u&lt;=3;$u++) {
    $user=new AppBundle\Entity\User();
    $users[]=$user;
    try { 
       $entityManager-&gt;persist($user);
    } catch (\Exception $e) {
        var_dump($e);
  }   
  </code></pre>
  
  <p>And here is the content of User.php :</p>
  
  <pre><code>&lt;?php
  
  namespace AppBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use Symfony\Component\Validation\Constraints as Assert;
  
  /**
  * @ORM\Entity
  * @ORM\Table(name="user")
  *
  **/
  
  class User 
  {
      /**
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       * @ORM\Column(type="integer")
       */
      private $id;
  
      /**
       * @ORM\OneToMany(
       *      targetEntity="Comment",
       *      mappedBy="post",
       *      orphanRemoval=true
       * )
       * 
       */
      private $comments;
  
      /**
       * @ORM\OneToMany(
       *      targetEntity="Post",
       *      mappedBy="post",
       *      orphanRemoval=true
       * )
       * 
       */
      private $posts;
       /**
       * Constructor
       */
      public function __construct()
      {
          $this-&gt;comments = new \Doctrine\Common\Collections\ArrayCollection();
          $this-&gt;posts = new \Doctrine\Common\Collections\ArrayCollection();
      }
  
      /**
       * Get id
       *
       * @return integer
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * Add comment
       *
       * @param \AppBundle\Entity\Comment $comment
       *
       * @return User
       */
      public function addComment(\AppBundle\Entity\Comment $comment)
      {
          $this-&gt;comments[] = $comment;
  
          return $this;
      }
  
      /**
       * Remove comment
       *
       * @param \AppBundle\Entity\Comment $comment
       */
      public function removeComment(\AppBundle\Entity\Comment $comment)
      {
          $this-&gt;comments-&gt;removeElement($comment);
      }
  
      /**
       * Get comments
       *
       * @return \Doctrine\Common\Collections\Collection
       */
      public function getComments()
      {
          return $this-&gt;comments;
      }
  
      /**
       * Add post
       *
       * @param \AppBundle\Entity\Posts $post
       *
       * @return User
       */
      public function addPost(\AppBundle\Entity\Posts $post)
      {
          $this-&gt;posts[] = $post;
  
          return $this;
      }
  
      /**
       * Remove post
       *
       * @param \AppBundle\Entity\Posts $post
       */
      public function removePost(\AppBundle\Entity\Posts $post)
      {
          $this-&gt;posts-&gt;removeElement($post);
      }
  
      /**
       * Get posts
       *
       * @return \Doctrine\Common\Collections\Collection
       */
      public function getPosts()
      {
          return $this-&gt;posts;
      } 
   }   
  </code></pre>
  
  <p>Any help appreciated.  </p>