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

RepositoryEntityController is incompatible with devtools #2438

Closed
muliyul opened this issue Dec 1, 2024 · 5 comments
Closed

RepositoryEntityController is incompatible with devtools #2438

muliyul opened this issue Dec 1, 2024 · 5 comments
Assignees
Labels
status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged

Comments

@muliyul
Copy link

muliyul commented Dec 1, 2024

Cannot run application with devtools org.springframework.boot:spring-boot-devtools

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'repositoryEntityController' defined in class path resource [org/springframework/data/rest/webmvc/RestControllerConfiguration.class]: Could not generate CGLIB subclass of class org.springframework.data.rest.webmvc.RepositoryEntityController: Common causes of this problem include using a final class or a non-visible class

Seems like RepositoryEntityController is non-visible (no public modifier).

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 1, 2024
@mp911de
Copy link
Member

mp911de commented Dec 2, 2024

Can you post the full stack trace (i.e. non-truncated)? We have quite a few package-protected types. I do not see why proxying would be necessary in a developer-facing project as you're not going to update these types.

@mp911de mp911de added the status: waiting-for-feedback We need additional information before we can continue label Dec 2, 2024
@muliyul
Copy link
Author

muliyul commented Dec 2, 2024

2024-12-02T15:34:06.263+02:00 ERROR 24868 --- [SharedSpot] [  restartedMain] [                                                 ] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'repositoryEntityController' defined in class path resource [org/springframework/data/rest/webmvc/RestControllerConfiguration.class]: Could not generate CGLIB subclass of class org.springframework.data.rest.webmvc.RepositoryEntityController: Common causes of this problem include using a final class or a non-visible class
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:608) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:523) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:336) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:288) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.instantiateSingleton(DefaultListableBeanFactory.java:1122) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingleton(DefaultListableBeanFactory.java:1093) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:1030) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:987) ~[spring-context-6.2.0.jar:6.2.0]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:627) ~[spring-context-6.2.0.jar:6.2.0]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.4.0.jar:3.4.0]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) ~[spring-boot-3.4.0.jar:3.4.0]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439) ~[spring-boot-3.4.0.jar:3.4.0]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:318) ~[spring-boot-3.4.0.jar:3.4.0]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1361) ~[spring-boot-3.4.0.jar:3.4.0]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1350) ~[spring-boot-3.4.0.jar:3.4.0]
	at com.muliyul.sharedspot.SharedSpotApplicationKt.main(SharedSpotApplication.kt:28) ~[main/:na]
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[na:na]
	at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50) ~[spring-boot-devtools-3.4.0.jar:3.4.0]
Caused by: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class org.springframework.data.rest.webmvc.RepositoryEntityController: Common causes of this problem include using a final class or a non-visible class
	at org.springframework.aop.framework.CglibAopProxy.buildProxy(CglibAopProxy.java:237) ~[spring-aop-6.2.0.jar:6.2.0]
	at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:167) ~[spring-aop-6.2.0.jar:6.2.0]
	at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110) ~[spring-aop-6.2.0.jar:6.2.0]
	at org.springframework.modulith.observability.ModuleTracingSupport.addAdvisor(ModuleTracingSupport.java:60) ~[spring-modulith-observability-1.3.0.jar:1.3.0]
	at org.springframework.modulith.observability.SpringDataRestModuleTracingBeanPostProcessor.postProcessAfterInitialization(SpringDataRestModuleTracingBeanPostProcessor.java:77) ~[spring-modulith-observability-1.3.0.jar:1.3.0]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:439) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1805) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601) ~[spring-beans-6.2.0.jar:6.2.0]
	... 20 common frames omitted
Caused by: org.springframework.cglib.core.CodeGenerationException: java.lang.IllegalAccessError-->class org.springframework.data.rest.webmvc.RepositoryEntityController$$SpringCGLIB$$0 cannot access its superclass org.springframework.data.rest.webmvc.RepositoryEntityController (org.springframework.data.rest.webmvc.RepositoryEntityController$$SpringCGLIB$$0 is in unnamed module of loader org.springframework.boot.devtools.restart.classloader.RestartClassLoader @422634da; org.springframework.data.rest.webmvc.RepositoryEntityController is in unnamed module of loader 'app')
	at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:490) ~[spring-core-6.2.0.jar:6.2.0]
	at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:371) ~[spring-core-6.2.0.jar:6.2.0]
	at org.springframework.cglib.proxy.Enhancer.generate(Enhancer.java:575) ~[spring-core-6.2.0.jar:6.2.0]
	at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.lambda$new$1(AbstractClassGenerator.java:107) ~[spring-core-6.2.0.jar:6.2.0]
	at org.springframework.cglib.core.internal.LoadingCache.lambda$createEntry$1(LoadingCache.java:52) ~[spring-core-6.2.0.jar:6.2.0]
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) ~[na:na]
	at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:57) ~[spring-core-6.2.0.jar:6.2.0]
	at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34) ~[spring-core-6.2.0.jar:6.2.0]
	at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:130) ~[spring-core-6.2.0.jar:6.2.0]
	at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:317) ~[spring-core-6.2.0.jar:6.2.0]
	at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:562) ~[spring-core-6.2.0.jar:6.2.0]
	at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:407) ~[spring-core-6.2.0.jar:6.2.0]
	at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:62) ~[spring-aop-6.2.0.jar:6.2.0]
	at org.springframework.aop.framework.CglibAopProxy.buildProxy(CglibAopProxy.java:228) ~[spring-aop-6.2.0.jar:6.2.0]
	... 27 common frames omitted
Caused by: java.lang.IllegalAccessError: class org.springframework.data.rest.webmvc.RepositoryEntityController$$SpringCGLIB$$0 cannot access its superclass org.springframework.data.rest.webmvc.RepositoryEntityController (org.springframework.data.rest.webmvc.RepositoryEntityController$$SpringCGLIB$$0 is in unnamed module of loader org.springframework.boot.devtools.restart.classloader.RestartClassLoader @422634da; org.springframework.data.rest.webmvc.RepositoryEntityController is in unnamed module of loader 'app')
	at java.base/java.lang.ClassLoader.defineClass1(Native Method) ~[na:na]
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1027) ~[na:na]
	at org.springframework.boot.devtools.restart.classloader.RestartClassLoader.publicDefineClass(RestartClassLoader.java:147) ~[spring-boot-devtools-3.4.0.jar:3.4.0]
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[na:na]
	at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:486) ~[spring-core-6.2.0.jar:6.2.0]
	... 40 common frames omitted


Process finished with exit code 0

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Dec 2, 2024
@mp911de
Copy link
Member

mp911de commented Dec 3, 2024

Paging @odrotbohm @marcingrzejszczak

@marcingrzejszczak
Copy link

Is this the problem with the 1.3.0 version? We've migrated tracing support to observability based support (although that logic with cglib proxies might not have been changed)

@odrotbohm
Copy link
Member

I got this fixed by registering both Spring Data REST WebMVC and HAL Explorer to be included in the application classloader as documented here. I'll consult the Boot team to better understand why that is.

odrotbohm added a commit that referenced this issue Dec 11, 2024
We now declare explicit Spring Boot DevTools configuration to include Spring Data REST WebMVC and HAL Explorer in the restart classloader to prevent proxying issues with package protected types.

Fixes GH-2438.
odrotbohm added a commit that referenced this issue Dec 11, 2024
We now declare explicit Spring Boot DevTools configuration to include Spring Data REST WebMVC and HAL Explorer in the restart classloader to prevent proxying issues with package protected types.

Fixes GH-2438.
@odrotbohm odrotbohm added this to the 4.3.7 (2024.0.7) milestone Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

5 participants