David Patterson David Patterson - 4 months ago 41
PHP Question

Cache:clear fails with The annotation "@Doctrine\ORM\Mapping\HasLifeCycleCallbacks" ... does not exist

I'm trying to do a preview release for my customer.

Everything is working fine on my development host in the preview environment.

I created a tarball excluding the stuff that isn't needed on the live site.

tar \
--create \
--auto-compress \
--dereference \
--exclude=.DS_Store \
--exclude=.git \
--exclude=.idea \
--exclude=.nfs* \
--exclude=node_modules \
--exclude=tests \
--exclude=var/cache/* \
--exclude=ToDo* \
--exclude=var/logs/* \
--exclude=var/sessions/* \
--exclude=web/tickets/* \
--file ./preview.tgz


I transferred the tarball to the target host and unpacked it.

Then cded into the directory and issued

sudo bin/console cache:clear --env=preview


Symfony throws the following error:


[Doctrine\Common\Annotations\AnnotationException]

[Semantical Error] The annotation "@Doctrine\ORM\Mapping\HasLifeCycleCallbacks" in class Bcs\BcsVmsUserBundle\Entity\VmsUser does not exist, or could not be auto-loaded.


I have manually deleted the contents of the cache directory and still get this error.

2016-0801-1124: Additional information.


  • I re-generated the auto-load files on the target host. No change.

  • I verified that the the HasLifeCycleCallbacks class is defined in the autoload files. It's in autoload_static.php and in autoload_classmap.php.

  • I verified that the file specified in the auto-load files does, indeed, exist.



Verbose output from
console cache:clear --env=preview


[Doctrine\Common\Annotations\AnnotationException]
[Semantical Error] The annotation "@Doctrine\ORM\Mapping\HasLifeCycleCallbacks" in class Bcs\BcsVmsUserBundle\Entity\VmsUser does not exist, or could not be auto-loaded.


Exception trace:
() at /var/www/wwui/preview/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php:54
Doctrine\Common\Annotations\AnnotationException::semanticalError() at /var/www/wwui/preview/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php:708
Doctrine\Common\Annotations\DocParser->Annotation() at /var/www/wwui/preview/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php:641
Doctrine\Common\Annotations\DocParser->Annotations() at /var/www/wwui/preview/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php:334
Doctrine\Common\Annotations\DocParser->parse() at /var/www/wwui/preview/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php:195
Doctrine\Common\Annotations\AnnotationReader->getClassAnnotations() at /var/www/wwui/preview/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/CachedReader.php:83
Doctrine\Common\Annotations\CachedReader->getClassAnnotations() at /var/www/wwui/preview/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php:63
Doctrine\ORM\Mapping\Driver\AnnotationDriver->loadMetadataForClass() at /var/www/wwui/preview/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php:102
Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain->loadMetadataForClass() at /var/www/wwui/preview/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:151
Doctrine\ORM\Mapping\ClassMetadataFactory->doLoadMetadata() at /var/www/wwui/preview/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:332
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->loadMetadata() at /var/www/wwui/preview/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:78
Doctrine\ORM\Mapping\ClassMetadataFactory->loadMetadata() at /var/www/wwui/preview/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:216
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor() at /var/www/wwui/preview/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:281
Doctrine\ORM\EntityManager->getClassMetadata() at /var/www/wwui/preview/vendor/doctrine/orm/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php:44
Doctrine\ORM\Repository\DefaultRepositoryFactory->getRepository() at /var/www/wwui/preview/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:698
Doctrine\ORM\EntityManager->getRepository() at /var/www/wwui/preview/var/cache/preview/appPreviewDebugProjectContainer.php:450
appPreviewDebugProjectContainer->getBcs_Vmsuser_RepositoryService() at /var/www/wwui/preview/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php:275
Symfony\Component\DependencyInjection\Container->get() at /var/www/wwui/preview/var/cache/preview/appPreviewDebugProjectContainer.php:437
appPreviewDebugProjectContainer->getBcs_Vmsuser_LoaderService() at /var/www/wwui/preview/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php:275
Symfony\Component\DependencyInjection\Container->get() at /var/www/wwui/preview/var/cache/preview/appPreviewDebugProjectContainer.php:411
appPreviewDebugProjectContainer->getBcs_Vmsuser_AuthenticatorService() at /var/www/wwui/preview/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php:275
Symfony\Component\DependencyInjection\Container->get() at /var/www/wwui/preview/var/cache/preview/appPreviewDebugProjectContainer.php:4403
appPreviewDebugProjectContainer->getSecurity_Authentication_ManagerService() at /var/www/wwui/preview/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php:275
Symfony\Component\DependencyInjection\Container->get() at /var/www/wwui/preview/var/cache/preview/appPreviewDebugProjectContainer.php:2476
appPreviewDebugProjectContainer->getSecurity_AuthorizationCheckerService() at /var/www/wwui/preview/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php:275
Symfony\Component\DependencyInjection\Container->get() at /var/www/wwui/preview/var/cache/preview/appPreviewDebugProjectContainer.php:1103
appPreviewDebugProjectContainer->getDplhMenuUtilityService() at /var/www/wwui/preview/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php:275
Symfony\Component\DependencyInjection\Container->get() at /var/www/wwui/preview/var/cache/preview/appPreviewDebugProjectContainer.php:1077
appPreviewDebugProjectContainer->getDplhMenuDebugCommandService() at /var/www/wwui/preview/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php:275
Symfony\Component\DependencyInjection\Container->get() at /var/www/wwui/preview/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:123
Symfony\Bundle\FrameworkBundle\Console\Application->registerCommands() at /var/www/wwui/preview/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:98
Symfony\Bundle\FrameworkBundle\Console\Application->all() at /var/www/wwui/preview/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:72
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/wwui/preview/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:117
Symfony\Component\Console\Application->run() at /var/www/wwui/preview/bin/console:29


Development host:


  • Ubuntu 14.04.4 LTS

  • PHP 7.0.7-4

  • Symfony 3.1.2



Target host:


  • Ubuntu 16.04.1 LTS

  • PHP 7.0.8-0

  • Symfony 3.1.2 (as part of the tarball)



Suggestions?

Answer

Turns out @Doctrine\ORM\Mapping\HasLifeCycleCallbacks should be @Doctrine\ORM\Mapping\HasLifecycleCallbacks (that's a lowercase c in cycle).

I develop on a Mac which has case-insensitive file systems, by default and deploy to Ubuntu.

Many thanks to sfix and trq on the #symfony IRC node for this answer.

Comments