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

AspectJ doesn't work when bean is defined as the interface in configuration for a native application #35049

Closed
Ferioney opened this issue Apr 18, 2023 · 1 comment
Labels
for: external-project For an external project and not something we can fix status: invalid An issue that we don't feel is valid

Comments

@Ferioney
Copy link

When I declared bean as a class in configuration Aspect worked as expected, but when as an interface - application failed.

I prepared a small demo to show the issue: demo_aspect_native.

Steps:

  • provide service bean as class: bean declaration
  • run application as regular app
  • GET /home and see that Aspect works: "From aspect: Welcome!"
  • stop app
  • build native application: mvn -Pnative native:compile
  • run app: ./target/demo
  • GET /home and see that Aspect works: "From aspect: Welcome!"
  • change service bean declaration from class to interface (from DefaultHomeService to HomeService in bean declaration)
  • build native application: mvn -Pnative native:compile
  • run app: ./target/demo: application doesn't start with error:
Caused by: java.lang.IllegalArgumentException: error Type referred to is not an annotation type: com$example$demo$logic$AspectAnnotation
        at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:319) ~[demo:na]
        at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:222) ~[na:na]
        at org.springframework.aop.aspectj.AspectJExpressionPointcut.obtainPointcutExpression(AspectJExpressionPointcut.java:193) ~[na:na]
        at org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:172) ~[na:na]

In my real project (with almost the same configuration) when I declared a bean as an interface application started. but aspect doesn't work.
Thanks!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 18, 2023
@wilkinsona
Copy link
Member

Support for aspects in a native image is a Spring Framework feature. Please review spring-projects/spring-framework#28711 which may be relevant here. If you feel that you have a different problem that is not covered by 28711, please open a new Spring Framework issue.

@wilkinsona wilkinsona closed this as not planned Won't fix, can't repro, duplicate, stale Apr 18, 2023
@wilkinsona wilkinsona added status: invalid An issue that we don't feel is valid for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

3 participants