title: Spring Boot fails to start up: Could not generate CGLIB subclass of class BasicErrorController
body: <p>I'm upgrading our Spring-Boot application (2.5.6) to use Java 17 and we are going from <code>amazoncorretto:11-al2-jdk</code> to <code>amazoncorretto:17-al2-jdk</code> which uses a distribution of OpenJDK 17.</p>
  <p>After bumping our Docker base image to <code>amazoncorretto:17-al2-jdk</code> and wrap it all up in a docker image, the application fails to start up due to:</p>
  <pre><code>Could not generate CGLIB subclass of class org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController: 
  Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException:
  java.lang.LinkageError--&gt;loader org.springframework.boot.loader.LaunchedURLClassLoader @17a7cec2
  attempted duplicate class definition for org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController$$EnhancerBySpringCGLIB$$aee9141f.
  </code></pre>
  <p>Based on the error message it seems that Spring tries to generate a subclass of <code>BasicErrorController</code> but fails due to <code>attempted duplicate class definition</code>. (The BasicErrorController comes from a  Spring-Boot library). I have tried reading up on the CGLIB logic but I can not figure out whats wrong/duplicated class (and I can not find any final classes as the error message suggestion implies).</p>
  <p>Any ideas what I can do to resolve this issue?</p>
  <p>When I run the application directly from the IntelliJ IDE using the same jdk17 as in the docker image, it works fine.</p>
  <hr />
  <p>edit: some more logs with stacktraces and DEBUG level enabled</p>
  <pre><code>       DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration' 
  DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration$DefaultErrorViewResolverConfiguration' 
  DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Autowiring by type from bean name 'org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration$DefaultErrorViewResolverConfiguration' via constructor to bean named 'org.springframework.web.context.support.AnnotationConfigWebApplicationContext@5b40de43' 
  DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Autowiring by type from bean name 'org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration$DefaultErrorViewResolverConfiguration' via constructor to bean named 'spring.resources-org.springframework.boot.autoconfigure.web.ResourceProperties' 
  DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Autowiring by type from bean name 'org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration$DefaultErrorViewResolverConfiguration' via constructor to bean named 'spring.web-org.springframework.boot.autoconfigure.web.WebProperties' 
  DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'errorAttributes' 
  DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'basicErrorController' 
  DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Autowiring by type from bean name 'basicErrorController' via factory method to bean named 'errorAttributes' 
  WARN  org.springframework.web.context.support.AnnotationConfigWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'basicErrorController' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.LinkageError--&gt;loader org.springframework.boot.loader.LaunchedURLClassLoader @17a7cec2 attempted duplicate class definition for org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController$$EnhancerBySpringCGLIB$$3b1a7b57. (org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController$$EnhancerBySpringCGLIB$$3b1a7b57 is in unnamed module of loader org.springframework.boot.loader.LaunchedURLClassLoader @17a7cec2, parent loader 'app') 
  ERROR org.springframework.web.servlet.DispatcherServlet - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'basicErrorController' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.LinkageError--&gt;loader org.springframework.boot.loader.LaunchedURLClassLoader @17a7cec2 attempted duplicate class definition for org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController$$EnhancerBySpringCGLIB$$3b1a7b57. (org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController$$EnhancerBySpringCGLIB$$3b1a7b57 is in unnamed module of loader org.springframework.boot.loader.LaunchedURLClassLoader @17a7cec2, parent loader 'app')
      ... suppressed 17 lines
      at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[?:?]
      at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) ~[?:?]
      at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762) ~[?:?]
      at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276) ~[?:?]
      at java.util.TreeMap$ValueSpliterator.forEachRemaining(TreeMap.java:3215) ~[?:?]
      at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[?:?]
      at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[?:?]
      at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[?:?]
      at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[?:?]
      at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
      at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[?:?]
      ... suppressed 9 lines
      at java.lang.Iterable.forEach(Iterable.java:75) [?:?]
      ... suppressed 8 lines
      at xxx.xxx.Application.main(Application.java:62) [classes!/:?]
      ... suppressed 8 lines
   Caused by: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.LinkageError--&gt;loader org.springframework.boot.loader.LaunchedURLClassLoader @17a7cec2 attempted duplicate class definition for org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController$$EnhancerBySpringCGLIB$$3b1a7b57. (org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController$$EnhancerBySpringCGLIB$$3b1a7b57 is in unnamed module of loader org.springframework.boot.loader.LaunchedURLClassLoader @17a7cec2, parent loader 'app')
      ... suppressed 8 lines
      ... 54 more
   Caused by: org.springframework.cglib.core.CodeGenerationException: java.lang.LinkageError--&gt;loader org.springframework.boot.loader.LaunchedURLClassLoader @17a7cec2 attempted duplicate class definition for org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController$$EnhancerBySpringCGLIB$$3b1a7b57. (org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController$$EnhancerBySpringCGLIB$$3b1a7b57 is in unnamed module of loader org.springframework.boot.loader.LaunchedURLClassLoader @17a7cec2, parent loader 'app')
      ... suppressed 22 lines
      ... 54 more
   Caused by: java.lang.LinkageError: loader org.springframework.boot.loader.LaunchedURLClassLoader @17a7cec2 attempted duplicate class definition for org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController$$EnhancerBySpringCGLIB$$3b1a7b57. (org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController$$EnhancerBySpringCGLIB$$3b1a7b57 is in unnamed module of loader org.springframework.boot.loader.LaunchedURLClassLoader @17a7cec2, parent loader 'app')
      at java.lang.ClassLoader.defineClass0(Native Method) ~[?:?]
      at java.lang.System$2.defineClass(System.java:2307) ~[?:?]
      at java.lang.invoke.MethodHandles$Lookup$ClassDefiner.defineClass(MethodHandles.java:2439) ~[?:?]
      at java.lang.invoke.MethodHandles$Lookup$ClassDefiner.defineClass(MethodHandles.java:2416) ~[?:?]
      at java.lang.invoke.MethodHandles$Lookup.defineClass(MethodHandles.java:1843) ~[?:?]
      ... suppressed 25 lines
      ... 54 more
    
   org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'basicErrorController' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.LinkageError--&gt;loader org.springframework.boot.loader.LaunchedURLClassLoader @17a7cec2 attempted duplicate class definition for org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController$$EnhancerBySpringCGLIB$$3b1a7b57. (org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController$$EnhancerBySpringCGLIB$$3b1a7b57 is in unnamed module of loader org.springframework.boot.loader.LaunchedURLClassLoader @17a7cec2, parent loader 'app')
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:628)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
      at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
      at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:702)
      at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:578)
      at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:530)
      at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:170)
      at javax.servlet.GenericServlet.init(GenericServlet.java:203)
      at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1164)
      at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1013)
      at org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedContext.load(TomcatEmbeddedContext.java:82)
      at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
      at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
      at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
      at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276)
      at java.base/java.util.TreeMap$ValueSpliterator.forEachRemaining(TreeMap.java:3215)
      at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
      at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
      at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
      at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
      at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
      at org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedContext.lambda$deferredLoadOnStartup$0(TomcatEmbeddedContext.java:65)
      at org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedContext.doWithThreadContextClassLoader(TomcatEmbeddedContext.java:106)
      at org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedContext.deferredLoadOnStartup(TomcatEmbeddedContext.java:64)
      at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.performDeferredLoadOnStartup(TomcatWebServer.java:305)
      at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:216)
      at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:43)
      at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178)
      at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54)
      at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356)
      at java.base/java.lang.Iterable.forEach(Iterable.java:75)
      at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155)
      at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123)
      at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)
      at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
      at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
      at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:338)
      at xxx.xxx.application.Application.main(Application.java:62)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:568)
      at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
      at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
      at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
      at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
   Caused by: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.LinkageError--&gt;loader org.springframework.boot.loader.LaunchedURLClassLoader @17a7cec2 attempted duplicate class definition for org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController$$EnhancerBySpringCGLIB$$3b1a7b57. (org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController$$EnhancerBySpringCGLIB$$3b1a7b57 is in unnamed module of loader org.springframework.boot.loader.LaunchedURLClassLoader @17a7cec2, parent loader 'app')
      at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:209)
      at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110)
      at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:478)
      at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:342)
      at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:291)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:455)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1808)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
      ... 54 more
   Caused by: org.springframework.cglib.core.CodeGenerationException: java.lang.LinkageError--&gt;loader org.springframework.boot.loader.LaunchedURLClassLoader @17a7cec2 attempted duplicate class definition for org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController$$EnhancerBySpringCGLIB$$3b1a7b57. (org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController$$EnhancerBySpringCGLIB$$3b1a7b57 is in unnamed module of loader org.springframework.boot.loader.LaunchedURLClassLoader @17a7cec2, parent loader 'app')
      at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:580)
      at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:363)
      at org.springframework.cglib.proxy.Enhancer.generate(Enhancer.java:585)
      at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:110)
      at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:108)
      at org.springframework.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54)
      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61)
      at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)
      at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:134)
      at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:319)
      at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:572)
      at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:419)
      at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:57)
      at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:206)
      ... 61 more
   Caused by: java.lang.LinkageError: loader org.springframework.boot.loader.LaunchedURLClassLoader @17a7cec2 attempted duplicate class definition for org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController$$EnhancerBySpringCGLIB$$3b1a7b57. (org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController$$EnhancerBySpringCGLIB$$3b1a7b57 is in unnamed module of loader org.springframework.boot.loader.LaunchedURLClassLoader @17a7cec2, parent loader 'app')
      at java.base/java.lang.ClassLoader.defineClass0(Native Method)
      at java.base/java.lang.System$2.defineClass(System.java:2307)
      at java.base/java.lang.invoke.MethodHandles$Lookup$ClassDefiner.defineClass(MethodHandles.java:2439)
      at java.base/java.lang.invoke.MethodHandles$Lookup$ClassDefiner.defineClass(MethodHandles.java:2416)
      at java.base/java.lang.invoke.MethodHandles$Lookup.defineClass(MethodHandles.java:1843)
      at java.base/jdk.internal.reflect.GeneratedMethodAccessor39.invoke(Unknown Source)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:568)
      at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:577)
      ... 75 more
   
  ...
   
  WARN  org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server 
  DEBUG org.springframework.data.redis.listener.RedisMessageListenerContainer - Stopped RedisMessageListenerContainer 
  INFO  org.springframework.scheduling.quartz.SchedulerFactoryBean - Shutting down Quartz Scheduler 
  DEBUG org.springframework.scheduling.quartz.LocalDataSourceJobStore - JobStore background threads shutdown. 
  DEBUG org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler - Shutting down ExecutorService 'taskScheduler' 
  DEBUG org.springframework.security.web.FilterChainProxy - Securing GET /ping 
  DEBUG org.springframework.security.web.context.SecurityContextPersistenceFilter - Set SecurityContextHolder to empty SecurityContext 
  DEBUG org.springframework.security.web.FilterChainProxy - Secured GET /ping 
  DEBUG org.springframework.security.web.context.SecurityContextPersistenceFilter - Cleared SecurityContextHolder to complete request 
  INFO  org.springframework.web.servlet.DispatcherServlet - Initializing Servlet 'web' 
  </code></pre>
  <hr />
  <p><strong>Update</strong>: I managed to identify the file that is causing the issue. If I remove that file it works fine on JDK17.</p>
  <p>After looking into the aspect logic a bit, can see that this code adds the advice on <em>all</em> controllers. After adding a package pointcut restriction to my app it works fine to start up <code>@Pointcut(&quot;within(one.goranson..*)&quot;)</code>.</p>
  <pre><code>@Aspect
  @Component
  @RequiredArgsConstructor
  class ProcessingTimeAspect {
  
    @Pointcut(&quot;@annotation(requestMapping)&quot;)
    void requestMappingMethod(RequestMapping requestMapping) {
      // pointcuts are empty
    }
  
    @Pointcut(&quot;@target(restController)&quot;)
    void restController(RestController restController) {
      // pointcuts are empty
    }
  
    @SuppressWarnings(&quot;null&quot;)
    @Nullable
    @Around(&quot;requestMappingMethod(requestMapping) &amp;&amp; restController(restController)&quot;)
    Object around(ProceedingJoinPoint joinPoint, RequestMapping requestMapping,
        RestController restController) throws Throwable {
      // Some unrelated code removed for measure request processing
      return joinPoint.proceed();
    }
  
  }
  </code></pre>