title: Symfony2 production environment: Mapping exception due to custom User class not found in chain configuration
body: <p>I'm developing a bit complex Symfony2.1 based app, with connection to two different databases (with two entity managers, one connected to Oracle and the other one to PostgreSQL) and a custom User class (with a custom password encoder).</p>
  
  <p>I've managed to have it running correctly in dev environment, but whenever I try to run it in production environment I'm getting the next error:</p>
  
  <p><strong>Doctrine\Common\Persistence\Mapping\MappingException: The class 'MyFirm\UserManagerBundle\Entity\User' was not found in the chain configured namespaces  (uncaught exception)</strong></p>
  
  <p>My security and encoders in app/config/security.yml:</p>
  
  <pre><code>security:
    encoders:
      MyFirm\UserManagerBundle\Entity\User:
          id: myfirm_usermanager.password_encoder
  
    providers:
      user_db:
          entity: 
              class: MyFirm\UserManagerBundle\Entity\User
              property: username 
  </code></pre>
  
  <p>The doctrine.orm section in app/config/config.yml:</p>
  
  <pre><code>doctrine:
    orm:
      auto_generate_proxy_classes: %kernel.debug%
      default_entity_manager: user_config_db 
      entity_managers:
          event_db:
              connection:   event_db
              mappings:
                  MyFirmEventManagerBundle: ~
          user_config_db:
              connection:   user_config_db
              mappings:
                  MyFirmUserManagerBundle:  ~
  </code></pre>
  
  <p>And finally, this is the final Exception log:</p>
  
  <pre><code>Exception trace:
   () at C:\SF2_project\vendor\doctrine\common\lib\Doctrine\Common\Persistence\Mapping\MappingException.php:38
   Doctrine\Common\Persistence\Mapping\MappingException::classNotFoundInNamespaces() at C:\SF2_project\vendor\doctrine\common\lib\Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain.php:114
   Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain-&gt;loadMetadataForClass() at C:\SF2_project\vendor\doctrine\orm\lib\Doctrine\ORM\Mapping\ClassMetadataFactory.php:112
   Doctrine\ORM\Mapping\ClassMetadataFactory-&gt;doLoadMetadata() at C:\SF2_project\vendor\doctrine\common\lib\Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory.php:302
   Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory-&gt;loadMetadata() at C:\SF2_project\vendor\doctrine\common\lib\Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory.php:205
   Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory-&gt;getMetadataFor() at C:\SF2_project\vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager.php:268
   Doctrine\ORM\EntityManager-&gt;getClassMetadata() at C:\SF2_project\app\cache\prod\jms_diextra\doctrine\EntityManager_5075a0dd6e27a.php:345
   EntityManager5075a0dd6e27a_546a8d27f194334ee012bfe64f629947b07e4919\__CG__\Doctrine\ORM\EntityManager-&gt;getClassMetadata() at C:\SF2_project\vendor\symfony\symfony\src\Symfony\Bridge\Doctrine\Security\User\EntityUserProvider.php:39
   Symfony\Bridge\Doctrine\Security\User\EntityUserProvider-&gt;__construct() at C:\SF2_project\app\cache\prod\appProdProjectContainer.php:1132
   appProdProjectContainer-&gt;getSecurity_User_Provider_Concrete_UserDbService() at C:\SF2_project\app\bootstrap.php.cache:211
   Symfony\Component\DependencyInjection\Container-&gt;get() at C:\SF2_project\app\cache\prod\appProdProjectContainer.php:1121
   appProdProjectContainer-&gt;getSecurity_User_Provider_Concrete_ChainProviderService() at C:\SF2_project\app\bootstrap.php.cache:211
   Symfony\Component\DependencyInjection\Container-&gt;get() at C:\SF2_project\app\cache\prod\appProdProjectContainer.php:1105
   appProdProjectContainer-&gt;getSecurity_Authentication_ManagerService() at C:\SF2_project\app\bootstrap.php.cache:211
   Symfony\Component\DependencyInjection\Container-&gt;get() at C:\SF2_project\app\cache\prod\appProdProjectContainer.php:552
   appProdProjectContainer-&gt;getSecurity_ContextService() at C:\SF2_project\app\bootstrap.php.cache:211
   Symfony\Component\DependencyInjection\Container-&gt;get() at C:\SF2_project\app\cache\prod\appProdProjectContainer.php:1002
   appProdProjectContainer-&gt;getTwigService() at C:\SF2_project\app\bootstrap.php.cache:211
   Symfony\Component\DependencyInjection\Container-&gt;get() at C:\SF2_project\app\cache\prod\appProdProjectContainer.php:30
   appProdProjectContainer-&gt;getAssetic_AssetManagerService() at C:\SF2_project\app\bootstrap.php.cache:211
   Symfony\Component\DependencyInjection\Container-&gt;get() at C:\SF2_project\vendor\symfony\assetic-bundle\Symfony\Bundle\AsseticBundle\CacheWarmer\AssetManagerCacheWarmer.php:33
   Symfony\Bundle\AsseticBundle\CacheWarmer\AssetManagerCacheWarmer-&gt;warmUp() at C:\SF2_project\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate.php:47
   Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate-&gt;warmUp() at C:\SF2_project\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Command\CacheWarmupCommand.php:64
   Symfony\Bundle\FrameworkBundle\Command\CacheWarmupCommand-&gt;execute() at C:\SF2_project\vendor\symfony\symfony\src\Symfony\Component\Console\Command\Command.php:238
   Symfony\Component\Console\Command\Command-&gt;run() at C:\SF2_project\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:193
   Symfony\Component\Console\Application-&gt;doRun() at C:\SF2_project\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Console\Application.php:78
   Symfony\Bundle\FrameworkBundle\Console\Application-&gt;doRun() at C:\SF2_project\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:106
   Symfony\Component\Console\Application-&gt;run() at C:\SF2_project\app\console:22
  </code></pre>
  
  <p>Has somebody any clue? Thanks a lot.</p>