Another "The class 'X' was not found in the chain configured namespaces

Eagle1 picture Eagle1 · Nov 25, 2013 · Viewed 7.2k times · Source

I get this error when I'm persisting my entity

Another "The class 'X' was not found in the chain configured namespaces

This used to work before I moved my Symfony from windows to Linux.

my controller:

public function SubscriptionHandlingAction(Request $request)
{

        if ($request->isMethod('POST')) 
        {

            $form = $this->createForm(new NewCustomer(), new Customer());
            $form->bind($request);

            if ($form->isValid()) 
            {

                // get the form data 
                $newcustomer = $form->getData();                    

                //get the date and set it in the entity
                $datecreation = new \DateTime(date('d-m-Y'));                     
                $newcustomer->setdatecreation($datecreation);

                //this works fine
                echo $newcustomer->getname();

                //persist the data
                $em = $this->getDoctrine()->getManager();
                $em->persist($newcustomer);
                $em->flush();


                return $this->render('NRtworksSubscriptionBundle:Subscription:subscription_success.html.twig');  

            }

Of course, my class entity exists, as I can create form based on it, objects etc. However, this entity is not "mapped" meaning doctrine:mapping:info doesn't give me anything (but I've created manually the corresponding sdl table and put all the annotations):

<?php

namespace NRtworks\SubscriptionBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;


/**
 * @ORM\Entity
 * @ORM\Table(name="Customer")
 */
class Customer
{

    /**
 * @ORM\Id
 * @ORM\Column(type="integer")
 * @ORM\GeneratedValue(strategy="AUTO")
 */

protected $idCustomer;

/**
 * @ORM\Column(type="string", length=100, unique = true)
 */

protected $name;  

 /**
 * @ORM\Column(type="string", length=50)
 */

protected $country;

 /**
 * @ORM\Column(type="datetime", nullable = false)
 */

protected $datecreation;

   /**
 * @ORM\Column(type="integer", length = 5, nullable = false)
 */

protected $admin_user;

//getter
// no need for that
// setter
// no need for that

}

?>

Any hint(s) of the issue ?

Big thanks

Answer

sjt003 picture sjt003 · Mar 20, 2014

Are you working with multiple entity managers or connections? Make sure each em matches with the corresponding bundles in config.yml under

doctrine:
  dbal:
    #connection info (driver/host/port/...)
  orm:
    entity_managers:
      manager_one:
      connection:  # your connection (eg: 'default:'
        mappings:
          YourRespectiveBundle: ~
          AnotherrespectiveBundle: ~

This tripped me up the first time I used multiple ems. Otherwise check AppKernel.php for your bundle, and double check the db connection is correct.