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

@EventListener doesn't work when @PreAuthorize is present on any interface method implemented by the same class [SPR-13866] #18439

spring-projects-issues opened this issue Jan 13, 2016 · 2 comments
in: core type: bug


Copy link

@spring-projects-issues spring-projects-issues commented Jan 13, 2016

Ruslan Stelmachenko opened SPR-13866 and commented

The @org.springframework.context.event.EventListener annotation doesn't work when is present on any method of interface implemented by the same class.

Also it is true if @PreAuthorize is present on class method which implements some interface method without annotations.

For example:

public interface MyService {

	public void restrictedMethod();


public class MyServiceImpl implements MyService {

	public void restrictedMethod() {

	public void processBlackListEvent(BlackListEvent event) {
		System.out.println("MyServiceImpl processBlackListEvent: " + event);


With this code processBlackListEvent method is never called when publishing BlackListEvent. Also we can place @PreAuthorize annotation to the implementation method and remove it from interface. In this case @EventListener also doesn't work.

If we remove @PreAuthorize then it starting to work again.

The old way with implementing ApplicationListener interface and overriding onApplicationEvent method also works fine.

Affects: 4.2.2

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jan 13, 2016

Juergen Hoeller commented

This should work as of 4.2.3, due to the work in #18226: In case of an AOP proxy, we also look at its target class for event listener annotations now.

At this point, please try against 4.2.4 and let me know if something is missing there still.


Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jan 14, 2016

Ruslan Stelmachenko commented

I tried it with 4.2.4 and it works now! Thanks!

@spring-projects-issues spring-projects-issues added type: bug in: core labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.2.3 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
in: core type: bug
None yet

No branches or pull requests

2 participants