Affects: 3.0.0
Hello, I am trying to upgrade from 2.7.5, but I am unable to start my applications when trying to migrate to Spring Boot 3.0. This is because all applications keep throwing the following exception during startup:
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field protected java.lang.Object[] java.util.Vector.elementData accessible: module java.base does not "opens java.util" to unnamed module @679b62af
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.Field.checkCanSetAccessible(Field.java:178) ~[na:na]
at java.base/java.lang.reflect.Field.setAccessible(Field.java:172) ~[na:na]
at org.springframework.util.ReflectionUtils.makeAccessible(ReflectionUtils.java:787) ~[spring-core-6.0.2.jar:6.0.2]
at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.doWith(AbstractMappingContext.java:536) ~[spring-data-commons-3.0.0.jar:3.0.0]
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:711) ~[spring-core-6.0.2.jar:6.0.2]
at org.springframework.data.mapping.context.AbstractMappingContext.doAddPersistentEntity(AbstractMappingContext.java:422) ~[spring-data-commons-3.0.0.jar:3.0.0]
at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:379) ~[spring-data-commons-3.0.0.jar:3.0.0]
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:280) ~[spring-data-commons-3.0.0.jar:3.0.0]
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:206) ~[spring-data-commons-3.0.0.jar:3.0.0]
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:92) ~[spring-data-commons-3.0.0.jar:3.0.0]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$6(RepositoryFactoryBeanSupport.java:282) ~[spring-data-commons-3.0.0.jar:3.0.0]
at java.base/java.util.Optional.ifPresent(Optional.java:178) ~[na:na]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:282) ~[spring-data-commons-3.0.0.jar:3.0.0]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:132) ~[spring-data-jpa-3.0.0.jar:3.0.0]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1797) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1747) ~[spring-beans-6.0.2.jar:6.0.2]
... 30 common frames omitted
This exception keeps occurring during bean initialization. And I cannot find ANY helpful results on Google; the only thing I've read about is that I might be using the wrong Java version, but I have tried Java 17 and 18; without any success whatsoever. Please help. This is horribly frustrating.
Comment From: jhoeller
Recent JDK versions enforce strict visibility rules even when going through reflection. Some part of your Spring Data setup is trying to dereference Vector.elementData
which is a protected
field and therefore not accessible anymore. Depending on the purpose there, maybe there is another way to handle access to those elements? Otherwise, you could start your JVM with -add-opens java.base/java.util=ALL-UNNAMED
to explicitly enable reflection into java.util
internals.
In any case, this is not a Spring Framework issue, I'll therefore close this ticket.