-
Notifications
You must be signed in to change notification settings - Fork 353
Spring AOP is only working for "concrete classes" #956
Comments
Could you please qualify this one @aclement ? |
Can you possibly share a small test project? In the annotation case, my immediate first thought is that the exception that says you need a proxy says you don't need a proxy for lots of things, you just are missing a proxy for these 3 types and I presume those 3 types don't match any of your point cuts.
So I would add the hint manually for that and see if it progresses further. That may just be a missing static hint we don't have. However, that's not to say there isn't an issue:
Yes, I imagine if doing load-time weaving (and not compile time weaving) all the types would need listing. What Spring Native has is all the building blocks of infrastructure so things are actually possible. The higher level analysis algorithms aren't all written (e.g. something that evaluates point cuts at build time and auto registers the necessary reflection entries and any proxies) - this is doable but hasn't been done yet (at least it is doable for reasonable uses of execution() and within() that scope to a set of types). If you do contribute a test project we can maybe use that as a basis to start fleshing it out. You could use the GraalVM agent to collect configuration so that at least the app will build into a native-image - that would be an interesting measure of whether it will fully behave when the build time analysis is written, or if there is some other problem lurking. Using the agent means you won't have to list all the types, the agent will simply produce it during collection. |
Ok thank you for the very complete information. You see to other Expressions that are commented out, only the active one works. I remeber that I also tried to set hints for Objectprocessor etc ... but afterwards, just other classes would come up that need to be annotated .. so i stopped there As you can see the project is pretty, pretty basic... The Quarkus people somehow managed to get it working without any hints ... just with the Thx for the support Andreas |
Created a new issue for Boot 3.0 |
Following the examples from the spring-native project, it is possible to weave aspects.
However this only works for very "concrete" classes.
This works:
@around("execution(public * org.goafabric.calleeservice.logic.CalleeLogic.*(..))")
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
A wildcard for all classes in logic does not:
@around("execution(public * org.goafabric.calleeservice.logic..*(..)) )")
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
=> See Wildcard Exception Below
Using an annotation is also not working:
@around("execution(public * *(..)) && within(@org.goafabric.calleeservice.crossfunctional.DurationLog *)")
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
@target(ElementType.TYPE)
@retention(RetentionPolicy.RUNTIME)
public @interface DurationLog {
}
=> See Annotation Exception
...
At this state it's pretty unusable, because they only choice would be than to list all classes that we want to weave.
Or am I missing something here ?
thx in advance
-- Wildcard Exception ---
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'metaDataSourceAdvisor':
Cannot resolve reference to bean 'methodSecurityMetadataSource' while setting constructor argument; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name
'org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration': Unsatisfied dependency expressed through method 'setObjectPostProcessor' parameter 0;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'objectPostProcessor' defined in class path resource [org/springframework/security/config/annotation/configuration/ObjectPostProcessorConfiguration.class]: Initialization of bean failed; nested exception is com.oracle.svm.core.jdk.UnsupportedFeatureError: Proxy class defined by interfaces [interface org.springframework.security.config.annotation.ObjectPostProcessor, interface org.springframework.beans.factory.DisposableBean, interface org.springframework.beans.factory.SmartInitializingSingleton] not found. Generating proxy classes at runtime is not supported. Proxy classes need to be defined at image build time by specifying the list of interfaces that they implement. To define proxy classes use -H:DynamicProxyConfigurationFiles= and -H:DynamicProxyConfigurationResources= options.
-- Annotation Exception --
'org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration':
Initialization of bean failed; nested exception is java.lang.IllegalArgumentException:
warning no match for this type name:
org.***.calleeservice.crossfunctional.DurationLog [Xlint:invalidAbsoluteTypeName]
The text was updated successfully, but these errors were encountered: