1

在 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]

堆栈跟踪

Doctrine\ORM\ORMException: Unrecognized field: randomId
at n/a
    in /home/johnny/Development/symfonyProject/vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php line 100

at Doctrine\ORM\ORMException::unrecognizedField('randomId')
    in /home/johnny/Development/symfonyProject/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php line 1681

at Doctrine\ORM\Persisters\BasicEntityPersister->getSelectConditionStatementColumnSQL('randomId', null)
    in /home/johnny/Development/symfonyProject/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php line 1610

at Doctrine\ORM\Persisters\BasicEntityPersister->getSelectConditionStatementSQL('randomId', 'fzhfyllumw0kwwgkocg80wkg8sc4ko0soww0cks4gc0ogggk', null)
    in /home/johnny/Development/symfonyProject/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php line 1701

at Doctrine\ORM\Persisters\BasicEntityPersister->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 Doctrine\ORM\Persisters\BasicEntityPersister->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 Doctrine\ORM\Persisters\BasicEntityPersister->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 Doctrine\ORM\EntityRepository->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 FOS\OAuthServerBundle\Entity\ClientManager->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 FOS\OAuthServerBundle\Model\ClientManager->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 FOS\OAuthServerBundle\Storage\OAuthStorage->getClient('fd87dddb-6c29-11e4-90f3-b8ca3aa16897_fzhfyllumw0kwwgkocg80wkg8sc4ko0soww0cks4gc0ogggk')
    in /home/johnny/Development/symfonyProject/vendor/friendsofsymfony/oauth2-php/lib/OAuth2/OAuth2.php line 707

at OAuth2\OAuth2->grantAccessToken(object(Request))
    in /home/johnny/Development/symfonyProject/vendor/friendsofsymfony/oauth-server-bundle/FOS/OAuthServerBundle/Controller/TokenController.php line 40

at FOS\OAuthServerBundle\Controller\TokenController->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 Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
    in /home/johnny/Development/symfonyProject/app/bootstrap.php.cache line 2938

at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
    in /home/johnny/Development/symfonyProject/app/bootstrap.php.cache line 3087

at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
    in /home/johnny/Development/symfonyProject/app/bootstrap.php.cache line 2337

at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
    in /home/johnny/Development/symfonyProject/web/app_dev.php line 18
4

1 回答 1

2

试试本节末尾的提示: https ://github.com/FriendsOfSymfony/FOSOAuthServerBundle/blob/master/Resources/doc/index.md#doctrine-orm-classes

似乎有人遇到了同样的问题并解决了,只需阅读文章下方的评论即可:

“如果您的学说配置中没有激活 auto_mapping,则需要将 FOSOAuthServerBundle 添加到 config.yml 中的映射中。”

于 2014-11-19T10:39:39.493 回答