Bug report:
When using Spring-Boot version 4.1.0-M3 and 4.1.0-M4, it seems the data persistence mechanism is not respecting the "@transient" annotation for a field in a Java class annotated with the mongoDb "@document" tag.
The attached zip file contains a modified version of repo "https://github.com/spring-guides/gs-accessing-data-mongodb.git"
In the modified code I added a field:
@Transient
private SecureRandom secureRandom;
to class "com.example.accessingdatamongodb.Customer".
If I set the spring boot version in file build.gradle to:
plugins {
id 'org.springframework.boot' version '4.1.0-M2'
}
The unit tests run without a problem.
If I change the spring boot version to 4.1.0-M3 or 4.1.0-M4
plugins {
id 'org.springframework.boot' version '4.1.0-M3'
}
I get the following exception:
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private java.security.Provider java.security.SecureRandom.provider accessible: module java.base does not "opens java.security" to unnamed module @32502377
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:803) ~[spring-core-7.0.6.jar:7.0.6]
at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.doWith(AbstractMappingContext.java:619) ~[spring-data-commons-4.1.0-M2.jar:4.1.0-M2]
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:727) ~[spring-core-7.0.6.jar:7.0.6]
at org.springframework.data.mapping.context.AbstractMappingContext.doAddPersistentEntity(AbstractMappingContext.java:474) ~[spring-data-commons-4.1.0-M2.jar:4.1.0-M2]
at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:426) ~[spring-data-commons-4.1.0-M2.jar:4.1.0-M2]
... 144 common frames omitted
Running on:
MacStudio with MacOs Tahoe 26.4.1
IntelliJ IDEA 2026.1.1 RC
Build #IU-261.23567.71, built on April 15, 2026
Gradlew version 9.4.1
Java version:
openjdk 26 2026-03-17
OpenJDK Runtime Environment Temurin-26+35 (build 26+35)
OpenJDK 64-Bit Server VM Temurin-26+35 (build 26+35, mixed mode, sharing)
Steps to reproduce:
- Unzip the attached files.
- Open the folder in Intellij or VSCode ( I use Intellij) -- or build and run from the command line directly.
- Edit the build.gradle file and set the spring boot version to 4.1.0-M2.
- Start docker (the project uses docker for mongo db test)
- Open the unit test file com.example.accessingdatamongodb.CustomerRepositoryTests and run any of the tests.
- The test should run.
- Edit the build.gradle file and change the spring boot verion to 4.1.0-M3.
- Reload the gradle project and rebuild.
- Run the same test again.
- You should get the exception above.
mongo-db-spring-example.zip
Bug report:
When using Spring-Boot version 4.1.0-M3 and 4.1.0-M4, it seems the data persistence mechanism is not respecting the "@transient" annotation for a field in a Java class annotated with the mongoDb "@document" tag.
The attached zip file contains a modified version of repo "https://github.com/spring-guides/gs-accessing-data-mongodb.git"
In the modified code I added a field:
to class "com.example.accessingdatamongodb.Customer".
If I set the spring boot version in file build.gradle to:
plugins { id 'org.springframework.boot' version '4.1.0-M2' }The unit tests run without a problem.
If I change the spring boot version to 4.1.0-M3 or 4.1.0-M4
plugins { id 'org.springframework.boot' version '4.1.0-M3' }I get the following exception:
Running on:
MacStudio with MacOs Tahoe 26.4.1
IntelliJ IDEA 2026.1.1 RC
Build #IU-261.23567.71, built on April 15, 2026
Gradlew version 9.4.1
Java version:
openjdk 26 2026-03-17
OpenJDK Runtime Environment Temurin-26+35 (build 26+35)
OpenJDK 64-Bit Server VM Temurin-26+35 (build 26+35, mixed mode, sharing)
Steps to reproduce:
mongo-db-spring-example.zip