Symfony:无法处理身份验证请求

In my UserProvider class the loadUserByUsername() method uses the query below, which throws an AuthenticationServiceException with the message: Authentication request could not be processed due to a system problem. What should be the problem? As others mentioned I cleared cache and update database schema by doctrine.

The query:

//...
$user = $this->entityManager->getRepository(User::class)->createQueryBuilder('u')
            ->where("u.userName = :username OR u.email = :email")
            ->setParameter('username', $username)
            ->setParameter('email', $username)
            ->getQuery()
            ->getOneOrNullResult(AbstractQuery::HYDRATE_OBJECT);
//...

Where did you set this query builder ? inside a repository class ? If you set this code inside a repository class, it is not necessary to use the entity manager. Or maybe do you have some reasons to do that. If not move your code inside user repository class like this :

// src/AppBundle/Repository/UserRepository.php
namespace AppBundle\Repository;

use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface;
use Doctrine\ORM\EntityRepository;

class UserRepository extends EntityRepository implements UserLoaderInterface
{
    public function loadUserByUsername($username)
    {
        return $this->createQueryBuilder('u')
            ->where('u.username = :username OR u.email = :email')
            ->setParameter('username', $username)
            ->setParameter('email', $username)
            ->getQuery()
            ->getOneOrNullResult();
    }
}

Don't forget :

Take a look : Custom Query to load the user