Comments (6)
We've not done much testing with JPMS unfortunately. It looks like DevToolsDataSourceAutoConfiguration
always assumes that javax.sql.DataSource
is available. We can add some extra guards but it looks like that might not be enough.
If I add requires java.sql;
to the module-info
class we get around the SQL error but hit:
org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InaccessibleObjectException-->Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @281e3708
at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:547) ~[spring-core-6.1.5.jar:6.1.5]
at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:371) ~[spring-core-6.1.5.jar:6.1.5]
at org.springframework.cglib.proxy.Enhancer.generate(Enhancer.java:575) ~[spring-core-6.1.5.jar:6.1.5]
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.lambda$new$1(AbstractClassGenerator.java:107) ~[spring-core-6.1.5.jar:6.1.5]
at org.springframework.cglib.core.internal.LoadingCache.lambda$createEntry$1(LoadingCache.java:52) ~[spring-core-6.1.5.jar:6.1.5]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:57) ~[spring-core-6.1.5.jar:6.1.5]
at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34) ~[spring-core-6.1.5.jar:6.1.5]
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:130) ~[spring-core-6.1.5.jar:6.1.5]
at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:317) ~[spring-core-6.1.5.jar:6.1.5]
at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:562) ~[spring-core-6.1.5.jar:6.1.5]
at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:407) ~[spring-core-6.1.5.jar:6.1.5]
at org.springframework.context.annotation.ConfigurationClassEnhancer.createClass(ConfigurationClassEnhancer.java:138) ~[spring-context-6.1.5.jar:6.1.5]
at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:109) ~[spring-context-6.1.5.jar:6.1.5]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:533) ~[spring-context-6.1.5.jar:6.1.5]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:310) ~[spring-context-6.1.5.jar:6.1.5]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:363) ~[spring-context-6.1.5.jar:6.1.5]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:153) ~[spring-context-6.1.5.jar:6.1.5]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:788) ~[spring-context-6.1.5.jar:6.1.5]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:606) ~[spring-context-6.1.5.jar:6.1.5]
at [email protected]/org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.2.4.jar:na]
at [email protected]/org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-3.2.4.jar:na]
at [email protected]/org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456) ~[spring-boot-3.2.4.jar:na]
at [email protected]/org.springframework.boot.SpringApplication.run(SpringApplication.java:334) ~[spring-boot-3.2.4.jar:na]
at [email protected]/org.springframework.boot.SpringApplication.run(SpringApplication.java:1354) ~[spring-boot-3.2.4.jar:na]
at [email protected]/org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-3.2.4.jar:na]
at bug.spring.security.jpms.main/org.example.bugspringsecurityjpms.BugSpringSecurityJpmsApplication.main(BugSpringSecurityJpmsApplication.java:10) ~[main/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50) ~[spring-boot-devtools-3.2.4.jar:3.2.4]
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @281e3708
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354) ~[na:na]
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297) ~[na:na]
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199) ~[na:na]
at java.base/java.lang.reflect.Method.setAccessible(Method.java:193) ~[na:na]
at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:505) ~[spring-core-6.1.5.jar:6.1.5]
... 31 common frames omitted
from spring-boot.
I don't think we need another bug, but I suspect we'll need to fix both before we can get devtools to work with JPMS.
from spring-boot.
I suspect spring-projects/spring-framework#32671 (already mentioned) getting fixed would resolve this other issue? or does spring framework need yet another bug?
from spring-boot.
I'm not 100% on this because my module-info set up is weird for testing with this feature variant... but since you're looking into things I'll leave this comment on actuator. I'll try creating a bug/repro in the next week. Saw this after changing spring-projects/spring-framework#32671 (comment)
Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/Module
at org.springframework.boot.actuate.autoconfigure.context.properties.ConfigurationPropertiesReportEndpointAutoConfiguration.configurationPropertiesReportEndpoint(ConfigurationPropertiesReportEndpointAutoConfiguration.java:51)
from spring-boot.
Given that we don't test Devtools, or any of Boot, with JPMS as it isn't a priority, I think we should focus this on the faulty assumption that javax.sql.DataSource
will always be available. DataSourceAutoConfiguration
does not make that assumption so DevToolsDataSourceAutoConfiguration
should not do so either. It may be enough on the Spring Boot side to get Devtools working with JPMS, but I'm not sure we should be claiming support for it unless we're prepared to test it.
from spring-boot.
A follow-up to the Spring Framework comments above: There is no obvious "fix" for spring-projects/spring-framework#32671 - it's a fundamental platform limitation rather than some kind of CGLIB legacy that we could do something about. If there is anything concrete that we can improve for SmartClassLoader.publicDefineClass
to empower the Boot RestartClassLoader, please let us know. Otherwise, we could only really add a stronger documentation note on these limitations.
from spring-boot.
Related Issues (20)
- After upgrading Spring Boot from 3.1.5 to 3.2.0 properties from application.yml are not read HOT 4
- Clarify that all named properties must match for @ConditionalOnProperty to match
- Clarify that all named properties must match for @ConditionalOnProperty to match
- Spring boot 3.2.5 crash if call wrong method HOT 4
- server.error.include-binding-errors does not recognize MethodValidationResult exceptions
- Stop expecting deprecation warnings in NativeImagePluginActionIntegrationTests
- Stop expecting deprecation warnings in NativeImagePluginActionIntegrationTests
- Add a test that verifies that the default for spring.data.mongodb.uuid-representation is aligned with Spring Data's default
- Add a test that verifies that the default for spring.data.mongodb.uuid-representation is aligned with Spring Data's default
- ServiceLevelObjectiveBoundary properties cannot be bound in a native image application
- Suggest testAndDevelopmentOnly configuration when using Docker Compose support in tests
- ServiceLevelObjectiveBoundary properties cannot be bound in a native image application
- ServiceLevelObjectiveBoundary properties cannot be bound in a native image application
- Runtime hint registration for property binding should not fail when parameter information is unavailable
- Runtime hint registration for property binding should not fail when parameter information is unavailable
- Bump gradle/actions from 3.3.0 to 3.3.1
- Bump gradle/actions from 3.3.0 to 3.3.1
- Consider delaying Jackson 2.17.0 upgrade in Spring Boot 3.3.0 HOT 2
- <springProperty> does not work in <include> after Logback upgrade HOT 5
- PulsarPropertiesMapper.getAuthenticationParamsJson HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-boot.