Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Argument 1 passed to "Symfony\Component\EventDispatcher\EventDispatcherInterface::dispatch()" must be an instance of Symfony\Component\EventDispatcher\Event, Lexik\Bundle\JWTAuthenticationBundle\Event\JWTAuthenticatedEvent given. #657

Closed
niepi opened this issue May 31, 2019 · 25 comments

Comments

@niepi
Copy link

niepi commented May 31, 2019

Hi, I'm getting the following error with Symfony 4.3

Argument 1 passed to "Symfony\Component\EventDispatcher\EventDispatcherInterface::dispatch()" must be an instance of Symfony\Component\EventDispatcher\Event, Lexik\Bundle\JWTAuthenticationBundle\Event\JWTAuthenticatedEvent given.

@chalasr
Copy link
Collaborator

chalasr commented May 31, 2019

EventDispatcherInterface::dispatch() does not have the Event typehint in 4.3. Are you sure that you correctly installed symfony/event-dispatcher to 4.3?

@niepi
Copy link
Author

niepi commented May 31, 2019

thx for the quick reply

just checked and rerun the upgrade

- Updating symfony/event-dispatcher (v4.2.6 => v4.3.0): Loading from cache

@chalasr
Copy link
Collaborator

chalasr commented May 31, 2019

Can you please show the full exception trace ? Is the cache properly cleared for the environment on which you're getting the error? A rm -rf var/cache/* could help eliminating the doubt :)

@niepi
Copy link
Author

niepi commented May 31, 2019

i did rm -rf var/cache/*

stack trace

TypeError:
Argument 1 passed to "Symfony\Component\EventDispatcher\EventDispatcherInterface::dispatch()" must be an instance of Symfony\Component\EventDispatcher\Event, Lexik\Bundle\JWTAuthenticationBundle\Event\JWTNotFoundEvent given.

  at vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:154
  at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch(object(JWTNotFoundEvent), object(JWTNotFoundEvent))
     (vendor/lexik/jwt-authentication-bundle/Security/Firewall/JWTListener.php:83)
  at Lexik\Bundle\JWTAuthenticationBundle\Security\Firewall\JWTListener->handle(object(RequestEvent))
     (vendor/symfony/security-bundle/Debug/WrappedListener.php:58)
  at Symfony\Bundle\SecurityBundle\Debug\WrappedListener->__invoke(object(RequestEvent))
     (vendor/symfony/security-bundle/Debug/TraceableFirewallListener.php:35)
  at Symfony\Bundle\SecurityBundle\Debug\TraceableFirewallListener->callListeners(object(RequestEvent), object(Generator))
     (vendor/symfony/security-http/Firewall.php:97)
  at Symfony\Component\Security\Http\Firewall->onKernelRequest(object(RequestEvent), 'kernel.request', object(TraceableEventDispatcher))
     (vendor/symfony/event-dispatcher/Debug/WrappedListener.php:126)
  at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(RequestEvent), 'kernel.request', object(TraceableEventDispatcher))
     (vendor/symfony/event-dispatcher/EventDispatcher.php:260)
  at Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.request', object(RequestEvent))
     (vendor/symfony/event-dispatcher/EventDispatcher.php:235)
  at Symfony\Component\EventDispatcher\EventDispatcher->callListeners(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.request', object(RequestEvent))
     (vendor/symfony/event-dispatcher/EventDispatcher.php:75)
  at Symfony\Component\EventDispatcher\EventDispatcher->dispatch(object(RequestEvent), 'kernel.request')
     (vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:168)
  at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch(object(RequestEvent), 'kernel.request')
     (vendor/symfony/http-kernel/HttpKernel.php:127)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/http-kernel/HttpKernel.php:68)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/http-kernel/Kernel.php:198)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (public/index.php:37)

@LemosT
Copy link

LemosT commented Jun 4, 2019

Also having the exact same problem.

@chalasr
Copy link
Collaborator

chalasr commented Jun 4, 2019

I will investigate this week, it might be a symfony bug.

@mickaelottmann
Copy link

same issue

@alexsoyes
Copy link

Same here since update from v4.2.4 => v4.3.1. Bonne chance.

@arifsetianto
Copy link

I had same issue, is there a solution for this?

@KDederichs
Copy link

KDederichs commented Jun 14, 2019

I have the same one but for the AuthenticationSuccessEvent, I assume it's related?

Symfony/Eventdispatcher 4.3.1 and event-dispatcher-contracts 1.1.1

Argument 1 passed to "Symfony\Component\EventDispatcher\EventDispatcherInterface::dispatch()" must be an instance of Symfony\Component\EventDispatcher\Event, Lexik\Bundle\JWTAuthenticationBundle\Event\AuthenticationSuccessEvent given.

@lucascardoso-egsys
Copy link

Same issue here. Any idea how can i fix it?

@lucascardoso-egsys
Copy link

I fixed this error. It occurred for me because i was overriding the AuthenticationSuccessHandler.

So I need copy again this classe from: https://github.com/lexik/LexikJWTAuthenticationBundle/blob/master/Security/Http/Authentication/AuthenticationSuccessHandler.php

and apply my changes again.

I hope it helps someone, cheers!!

@chalasr
Copy link
Collaborator

chalasr commented Jun 17, 2019

Can one of you please share the full exception trace?

@KDederichs
Copy link

Turned out to be related to something else in my codebase sorry

@mickaelottmann
Copy link

CRITICAL20:25:56 | php | Argument 1 passed to "Symfony\Component\EventDispatcher\EventDispatcherInterface::dispatch()" must be an instance of Symfony\Component\EventDispatcher\Event, Lexik\Bundle\JWTAuthenticationBundle\Event\JWTAuthenticatedEvent given.Show context    Hide trace{▼ /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php:154 {▶} /var/www/html/backend/vendor/lexik/jwt-authentication-bundle/Security/Authentication/Provider/JWTProvider.php:93 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authentication/AuthenticationProviderManager.php:80 {▶} /var/www/html/backend/vendor/lexik/jwt-authentication-bundle/Security/Firewall/JWTListener.php:96 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Bundle/SecurityBundle/Debug/WrappedListener.php:58 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Bundle/SecurityBundle/Debug/TraceableFirewallListener.php:35 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/Security/Http/Firewall.php:97 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php:126 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:260 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:235 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:75 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php:168 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:127 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:68 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:198 {▶} /var/www/html/backend/web/app_dev.php:14 {▼ › $request = Request::createFromGlobals(); › $response = $kernel->handle($request); › $response->send(); arguments: {▼ $request: Request {#53 …} } } } -- | -- | --

Uncaught PHP Exception TypeError: "Argument 1 passed to "Symfony\Component\EventDispatcher\EventDispatcherInterface::dispatch()" must be an instance of Symfony\Component\EventDispatcher\Event, Lexik\Bundle\JWTAuthenticationBundle\Event\JWTAuthenticatedEvent given." at /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php line 154 Hide context Hide trace [▼ "exception" => FatalThrowableError^ {#331 ▼ -originalClassName: "TypeError" #message: "Argument 1 passed to "Symfony\Component\EventDispatcher\EventDispatcherInterface::dispatch()" must be an instance of Symfony\Component\EventDispatcher\Event, Lexik\Bundle\JWTAuthenticationBundle\Event\JWTAuthenticatedEvent given." #code: 0 #file: "/var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php" #line: 154 #severity: E_RECOVERABLE_ERROR trace: {▼ /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php:154 {▶} /var/www/html/backend/vendor/lexik/jwt-authentication-bundle/Security/Authentication/Provider/JWTProvider.php:93 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authentication/AuthenticationProviderManager.php:80 {▶} /var/www/html/backend/vendor/lexik/jwt-authentication-bundle/Security/Firewall/JWTListener.php:96 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Bundle/SecurityBundle/Debug/WrappedListener.php:58 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Bundle/SecurityBundle/Debug/TraceableFirewallListener.php:35 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/Security/Http/Firewall.php:97 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php:126 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:260 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:235 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:75 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php:168 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:127 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:68 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:198 {▶} /var/www/html/backend/web/app_dev.php:14 {▼ › $request = Request::createFromGlobals(); › $response = $kernel->handle($request); › $response->send(); arguments: {▶} } } } ] {▼ /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php:154 {▶} /var/www/html/backend/vendor/lexik/jwt-authentication-bundle/Security/Authentication/Provider/JWTProvider.php:93 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authentication/AuthenticationProviderManager.php:80 {▶} /var/www/html/backend/vendor/lexik/jwt-authentication-bundle/Security/Firewall/JWTListener.php:96 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Bundle/SecurityBundle/Debug/WrappedListener.php:58 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Bundle/SecurityBundle/Debug/TraceableFirewallListener.php:35 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/Security/Http/Firewall.php:97 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php:126 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:260 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:235 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:75 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php:168 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:127 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:68 {▶} /var/www/html/backend/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:198 {▶} /var/www/html/backend/web/app_dev.php:14 {▼ › $request = Request::createFromGlobals(); › $response = $kernel->handle($request); › $response->send(); arguments: {▶} } }

@mickaelottmann
Copy link

I solved this issue by removing the first argument in
vendor/lexik/jwt-authentication-bundle/Security/Authentication/Provider/JWTProvider.php
line 93
but not sure it's the best solution, hope I helped you

@Evgeny1973
Copy link

Try $dispatcher->dispatch($event, OrderPlacedEvent::NAME);

@remoteclient
Copy link

I also get this error when I try to login with bad credentials.

@ghost
Copy link

ghost commented Jun 26, 2019

I solved patching this way, but I understand this needs further analysis to be fixed in a better way

<?php

namespace Lexik\Bundle\JWTAuthenticationBundle\Event;

use Symfony\Component\EventDispatcher\Event as BaseEvent;

class Event extends BaseEvent
{
}

@Webonaute
Copy link
Contributor

#669 should fix your issue

@Aylarius
Copy link

Aylarius commented Jul 2, 2019

While waiting for the fix to be merged, downgrading lexik/jwt-authentication-bundle to v2.6.1 worked out for me.

@sercul
Copy link

sercul commented Jul 12, 2019

I also have this issue

@jlaittom
Copy link

I have the same problem

@anjanasilva
Copy link

While waiting for the fix to be merged, downgrading lexik/jwt-authentication-bundle to v2.6.1 worked out for me.

Yes this did the trick. Thanks for the sage answer :).

@chalasr
Copy link
Collaborator

chalasr commented Jul 18, 2019

Fixed by #669

@chalasr chalasr closed this as completed Jul 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests