spring-native icon indicating copy to clipboard operation
spring-native copied to clipboard

Custom annotation used by @ControllerAdvice not detected (ClassNotFoundException)

Open leccelecce opened this issue 4 years ago • 0 comments

Java 11, Spring Boot 2.4.3 w/Spring MVC, Spring GraalVM Native 0.9.0-SNAPSHOT

I have a custom annotation defined as below:

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface AddNotificationsToModel {

}

This is then referenced by a @ControllerAdvice like so:

@ControllerAdvice(annotations = { AddNotificationsToModel.class })
@RequiredArgsConstructor
public class NavControllerAdvice {

The image builds correctly. At runtime however I get the following:

ERROR [main] [] o.s.b.SpringApplication: Application run failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.ecv.webapp.Application]; nested exception is java.lang.IllegalArgumentException: Could not find class [com.ecv.webapp.utils.AddNotificationsToModel]
...
Caused by: java.lang.ClassNotFoundException: com.ecv.webapp.utils.AddNotificationsToModel
        at com.oracle.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:60)
        at java.lang.Class.forName(DynamicHub.java:1260)
        at org.springframework.util.ClassUtils.forName(ClassUtils.java:284)
        at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:324)
        ... 28 more

leccelecce avatar Feb 22 '21 19:02 leccelecce