在Symfony2中,我正在尝试实现FOS\OAuthServerBundle,但遇到了一个奇怪的错误。按照这里的指南以及GitHub上的官方指南进行操作后,我遇到了一个错误,上面写着:
Unrecognized field: randomId
500 Internal Server Error - ORMException
这是 FOS\OAuthServerBundle 中客户端实体/模型中的受保护变量。我一定在这里错过了一些简单的东西,但对于我的生活,我无法弄清楚是什么。
还有其他人遇到过类似的错误吗?
尝试转到以下位置时会发生此错误:
http://symfony.local/app_dev.php/oauth/v2/token?grant_type=client_credentials&client_id=fd87dddb-6c29-11e4-90f3-b8ca3aa16897_fzhfyllumw0kwwgkocg80wkg8sc4ko0soww0cks4gc0ogggk&client_secret=[secret redacted]
堆栈跟踪
DoctrineORMORMException: Unrecognized field: randomId
at n/a
in /home/johnny/Development/symfonyProject/vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php line 100
at DoctrineORMORMException::unrecognizedField('randomId')
in /home/johnny/Development/symfonyProject/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php line 1681
at DoctrineORMPersistersBasicEntityPersister->getSelectConditionStatementColumnSQL('randomId', null)
in /home/johnny/Development/symfonyProject/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php line 1610
at DoctrineORMPersistersBasicEntityPersister->getSelectConditionStatementSQL('randomId', 'fzhfyllumw0kwwgkocg80wkg8sc4ko0soww0cks4gc0ogggk', null)
in /home/johnny/Development/symfonyProject/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php line 1701
at DoctrineORMPersistersBasicEntityPersister->getSelectConditionSQL(array('id' => 'fd87dddb-6c29-11e4-90f3-b8ca3aa16897', 'randomId' => 'fzhfyllumw0kwwgkocg80wkg8sc4ko0soww0cks4gc0ogggk'), null)
in /home/johnny/Development/symfonyProject/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php line 1115
at DoctrineORMPersistersBasicEntityPersister->getSelectSQL(array('id' => 'fd87dddb-6c29-11e4-90f3-b8ca3aa16897', 'randomId' => 'fzhfyllumw0kwwgkocg80wkg8sc4ko0soww0cks4gc0ogggk'), null, '0', '1', null, null)
in /home/johnny/Development/symfonyProject/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php line 746
at DoctrineORMPersistersBasicEntityPersister->load(array('id' => 'fd87dddb-6c29-11e4-90f3-b8ca3aa16897', 'randomId' => 'fzhfyllumw0kwwgkocg80wkg8sc4ko0soww0cks4gc0ogggk'), null, null, array(), '0', '1', null)
in /home/johnny/Development/symfonyProject/vendor/doctrine/orm/lib/Doctrine/ORM/EntityRepository.php line 196
at DoctrineORMEntityRepository->findOneBy(array('id' => 'fd87dddb-6c29-11e4-90f3-b8ca3aa16897', 'randomId' => 'fzhfyllumw0kwwgkocg80wkg8sc4ko0soww0cks4gc0ogggk'))
in /home/johnny/Development/symfonyProject/vendor/friendsofsymfony/oauth-server-bundle/FOS/OAuthServerBundle/Entity/ClientManager.php line 55
at FOSOAuthServerBundleEntityClientManager->findClientBy(array('id' => 'fd87dddb-6c29-11e4-90f3-b8ca3aa16897', 'randomId' => 'fzhfyllumw0kwwgkocg80wkg8sc4ko0soww0cks4gc0ogggk'))
in /home/johnny/Development/symfonyProject/vendor/friendsofsymfony/oauth-server-bundle/FOS/OAuthServerBundle/Model/ClientManager.php line 41
at FOSOAuthServerBundleModelClientManager->findClientByPublicId('fd87dddb-6c29-11e4-90f3-b8ca3aa16897_fzhfyllumw0kwwgkocg80wkg8sc4ko0soww0cks4gc0ogggk')
in /home/johnny/Development/symfonyProject/vendor/friendsofsymfony/oauth-server-bundle/FOS/OAuthServerBundle/Storage/OAuthStorage.php line 102
at FOSOAuthServerBundleStorageOAuthStorage->getClient('fd87dddb-6c29-11e4-90f3-b8ca3aa16897_fzhfyllumw0kwwgkocg80wkg8sc4ko0soww0cks4gc0ogggk')
in /home/johnny/Development/symfonyProject/vendor/friendsofsymfony/oauth2-php/lib/OAuth2/OAuth2.php line 707
at OAuth2OAuth2->grantAccessToken(object(Request))
in /home/johnny/Development/symfonyProject/vendor/friendsofsymfony/oauth-server-bundle/FOS/OAuthServerBundle/Controller/TokenController.php line 40
at FOSOAuthServerBundleControllerTokenController->tokenAction(object(Request))
in line
at call_user_func_array(array(object(TokenController), 'tokenAction'), array(object(Request)))
in /home/johnny/Development/symfonyProject/app/bootstrap.php.cache line 2976
at SymfonyComponentHttpKernelHttpKernel->handleRaw(object(Request), '1')
in /home/johnny/Development/symfonyProject/app/bootstrap.php.cache line 2938
at SymfonyComponentHttpKernelHttpKernel->handle(object(Request), '1', true)
in /home/johnny/Development/symfonyProject/app/bootstrap.php.cache line 3087
at SymfonyComponentHttpKernelDependencyInjectionContainerAwareHttpKernel->handle(object(Request), '1', true)
in /home/johnny/Development/symfonyProject/app/bootstrap.php.cache line 2337
at SymfonyComponentHttpKernelKernel->handle(object(Request))
in /home/johnny/Development/symfonyProject/web/app_dev.php line 18
末尾的提示:https://github.com/FriendsOfSymfony/FOSOAuthServerBundle/blob/master/Resources/doc/index.md#doctrine-orm-classes
似乎有人遇到了同样的问题并解决了它,只需阅读文章下面的评论
:"如果你没有在你的学说配置中激活auto_mapping你需要将FOSOAuthServerBundle添加到config.yml中的映射中。