FOS\OAuthServerBundle unrecognized field error

1.7k views Asked by At

In Symfony2 I'm trying to implement FOS\OAuthServerBundle, but am getting a weird error. After following the guide here and also the official guide on GitHub, I'm met with an error that says:

Unrecognized field: randomId
500 Internal Server Error - ORMException

This is a protected variable in the Client Entity/Model in FOS\OAuthServerBundle. I must be missing something simple here, but for the life of me I can not figure out what.

Has anyone else experienced a similar error to this?

This error happens when trying to go to:

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]

Stack trace

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
1

There are 1 answers

1
piotr.jura On BEST ANSWER

Try the tip at the end of this section: https://github.com/FriendsOfSymfony/FOSOAuthServerBundle/blob/master/Resources/doc/index.md#doctrine-orm-classes

It seems someone had the same problem and solved it, just read the comments below the article which is:

"If you don't have auto_mapping activated in your doctrine configuration you need to add FOSOAuthServerBundle to your mappings in config.yml."