Search code examples
apisymfonydocker-composesymfony4fosuserbundle

Symfony 4.4 FOS user-bundle api/auth/login Call to a member function findOneBy() on null


I'm using symfony 4.4 via docker and installed FOS user bundle some time ago. Everything was working fine but recently while trying to login, i keep getting the error

Call to a member function findOneBy() on null. The full trace is this

{
    "meta": {
        "code": 0,
        "message": "Call to a member function findOneBy() on null",
        "file": "/var/www/symfony/vendor/friendsofsymfony/user-bundle/Doctrine/UserManager.php",
        "line": 76,
        "trace": [
            {
                "file": "/var/www/symfony/vendor/friendsofsymfony/user-bundle/Model/UserManager.php",
                "line": 58,
                "function": "findUserBy"
            },
            {
                "file": "/var/www/symfony/vendor/friendsofsymfony/user-bundle/Security/UserProvider.php",
                "line": 93,
                "function": "findUserByUsername"
            },
            {
                "file": "/var/www/symfony/vendor/friendsofsymfony/user-bundle/Security/UserProvider.php",
                "line": 43,
                "function": "findUser"
            },
            {
                "file": "/var/www/symfony/vendor/symfony/security-core/User/ChainUserProvider.php",
                "line": 56,
                "function": "loadUserByUsername"
            },
            {
                "file": "/var/www/symfony/vendor/symfony/security-core/Authentication/Provider/DaoAuthenticationProvider.php",
                "line": 85,
                "function": "loadUserByUsername"
            },
            {
                "file": "/var/www/symfony/vendor/symfony/security-core/Authentication/Provider/UserAuthenticationProvider.php",
                "line": 65,
                "function": "retrieveUser"
            },
            {
                "file": "/var/www/symfony/vendor/symfony/security-core/Authentication/AuthenticationProviderManager.php",
                "line": 85,
                "function": "authenticate"
            },
            {
                "file": "/var/www/symfony/vendor/symfony/security-http/Firewall/UsernamePasswordJsonAuthenticationListener.php",
                "line": 137,
                "function": "authenticate"
            },
            {
                "file": "/var/www/symfony/vendor/symfony/security-bundle/Debug/WrappedLazyListener.php",
                "line": 49,
                "function": "authenticate"
            },
            {
                "file": "/var/www/symfony/vendor/symfony/security-http/Firewall/AbstractListener.php",
                "line": 27,
                "function": "authenticate"
            },
            {
                "file": "/var/www/symfony/vendor/symfony/security-bundle/Debug/TraceableFirewallListener.php",
                "line": 62,
                "function": "__invoke"
            },
            {
                "file": "/var/www/symfony/vendor/symfony/security-http/Firewall.php",
                "line": 98,
                "function": "callListeners"
            },
            {
                "file": "/var/www/symfony/vendor/symfony/event-dispatcher/Debug/WrappedListener.php",
                "line": 126,
                "function": "onKernelRequest"
            },
            {
                "file": "/var/www/symfony/vendor/symfony/event-dispatcher/EventDispatcher.php",
                "line": 264,
                "function": "__invoke"
            },
            {
                "file": "/var/www/symfony/vendor/symfony/event-dispatcher/EventDispatcher.php",
                "line": 239,
                "function": "doDispatch"
            },
            {
                "file": "/var/www/symfony/vendor/symfony/event-dispatcher/EventDispatcher.php",
                "line": 73,
                "function": "callListeners"
            },
            {
                "file": "/var/www/symfony/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php",
                "line": 168,
                "function": "dispatch"
            },
            {
                "file": "/var/www/symfony/vendor/symfony/http-kernel/HttpKernel.php",
                "line": 134,
                "function": "dispatch"
            },
            {
                "file": "/var/www/symfony/vendor/symfony/http-kernel/HttpKernel.php",
                "line": 80,
                "function": "handleRaw"
            },
            {
                "file": "/var/www/symfony/vendor/symfony/http-kernel/Kernel.php",
                "line": 201,
                "function": "handle"
            },
            {
                "file": "/var/www/symfony/public/index.php",
                "line": 25,
                "function": "handle"
            }
        ]
    },
    "links": {
        "self": "/api/auth/login"
    },
    "errors": [
        {
            "status": "500",
            "code": "INTERNAL_SERVER_ERROR",
            "title": "Internal Server Error"
        }
    ]
}

The register endpoint works pretty good at url api/auth/register and registers the new user.

Any ideas?


Solution

  • Finally i could solve the issue by permanently deleting the vendor folder and using composer install to install all packages again.

    Composer update didn't help at all.

    I'm still not sure what was the issue but the solution for this problem was that.