sonata-project / SonataMediaBundle

Symfony SonataMediaBundle
https://docs.sonata-project.org/projects/SonataMediaBundle
MIT License
450 stars 496 forks source link

Class Application\Sonata\MediaBundle\Document\Gallery does not exist #176

Closed marcoleong closed 12 years ago

marcoleong commented 12 years ago

I was trying to install SonataMediaBundle today, with dev-master, it raised this exception.

[ErrorException]                                                                                                                                                                                                                                                                                  
  Warning: class_parents(): Class Application\Sonata\MediaBundle\Document\Gallery does not exist and could not be loaded in
 /....../vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php line 40 

I was wondering why this appear while I haven't defined Application\Sonata\MediaBundle\Document\Gallery in anyplace. I have declared Application\Sonata\MediaBundle\Document\ODM\Gallery.

marcoleong commented 12 years ago

It happens when I run app/console cache:clear app/console doctrine:mongodb:cache:clear-metadata and app/console cache:clear --no-warmup, works fine. so I suppose that is due to cache warmer

marcoleong commented 12 years ago
[ErrorException]                                                                                                                                                                                                                                                                                  
  Warning: class_parents(): Class Application\Sonata\MediaBundle\Document\Gallery does not exist and could not be loaded in /Users/leongmarco/development/web_projects/marcoleong.sf21/ml.sf21/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php line 40  

Exception trace:
 () at /Users/leongmarco/development/web_projects/marcoleong.sf21/ml.sf21/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php:40
 Symfony\Component\HttpKernel\Debug\ErrorHandler->handle() at n/a:n/a
 class_parents() at /Users/leongmarco/development/web_projects/marcoleong.sf21/ml.sf21/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php:40
 Doctrine\Common\Persistence\Mapping\RuntimeReflectionService->getParentClasses() at /Users/leongmarco/development/web_projects/marcoleong.sf21/ml.sf21/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:241
 Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getParentClasses() at /Users/leongmarco/development/web_projects/marcoleong.sf21/ml.sf21/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:264
 Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->loadMetadata() at /Users/leongmarco/development/web_projects/marcoleong.sf21/ml.sf21/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:188
 Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor() at /Users/leongmarco/development/web_projects/marcoleong.sf21/ml.sf21/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:111
 Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getAllMetadata() at /Users/leongmarco/development/web_projects/marcoleong.sf21/ml.sf21/vendor/doctrine/mongodb-odm-bundle/Doctrine/Bundle/MongoDBBundle/CacheWarmer/ProxyCacheWarmer.php:75
 Doctrine\Bundle\MongoDBBundle\CacheWarmer\ProxyCacheWarmer->warmUp() at /Users/leongmarco/development/web_projects/marcoleong.sf21/ml.sf21/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php:47
 Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate->warmUp() at /Users/leongmarco/development/web_projects/marcoleong.sf21/ml.sf21/app/bootstrap.php.cache:864
 Symfony\Component\HttpKernel\Kernel->initializeContainer() at /Users/leongmarco/development/web_projects/marcoleong.sf21/ml.sf21/app/bootstrap.php.cache:564
 Symfony\Component\HttpKernel\Kernel->boot() at /Users/leongmarco/development/web_projects/marcoleong.sf21/ml.sf21/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:97
 Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->warmup() at /Users/leongmarco/development/web_projects/marcoleong.sf21/ml.sf21/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:75
 Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->execute() at /Users/leongmarco/development/web_projects/marcoleong.sf21/ml.sf21/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:239
 Symfony\Component\Console\Command\Command->run() at /Users/leongmarco/development/web_projects/marcoleong.sf21/ml.sf21/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:193
 Symfony\Component\Console\Application->doRun() at /Users/leongmarco/development/web_projects/marcoleong.sf21/ml.sf21/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:77
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /Users/leongmarco/development/web_projects/marcoleong.sf21/ml.sf21/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:106
 Symfony\Component\Console\Application->run() at /Users/leongmarco/development/web_projects/marcoleong.sf21/ml.sf21/app/console:22
marcoleong commented 12 years ago

Ok, I have found out the cause, the prefixed path is not correct by default.

[prefixes:protected] => Array
                                (
                                    [/Users/leongmarco/development/web_projects/marcoleong.sf21/ml.sf21/vendor/sonata-project/media-bundle/Sonata/MediaBundle/Resources/config/doctrine] => Sonata\MediaBundle\Document
                                    [/Users/leongmarco/development/web_projects/marcoleong.sf21/ml.sf21/src/Application/Sonata/MediaBundle/Resources/config/doctrine] => Application\Sonata\MediaBundle\Document
                                    [/Users/leongmarco/development/web_projects/marcoleong.sf21/ml.sf21/vendor/sonata-project/user-bundle/Sonata/UserBundle/Resources/config/doctrine] => Sonata\UserBundle\Document
                                    [/Users/leongmarco/development/web_projects/marcoleong.sf21/ml.sf21/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/Resources/config/doctrine] => FOS\UserBundle\Document
                                )

So I have to define in config.yml

 ApplicationSonataMediaBundle:
                    prefix: Application\Sonata\MediaBundle\Document\ODM