muser83 opened a new issue, #16287:
URL: https://github.com/apache/grails-core/issues/16287
### Expected Behavior
On Bootstrap phase, the application will create an user with admin
permissions and then, start successfully.
```
class BootStrap {
def springSecurityService
def init = { servletContext ->
environments {
development {
initData()
}
}
}
void initData() {
User.withTransaction {
if (Role.count() == 0) {
def password = UUID.randomUUID().toString()
def adminRole = new Role(authority:
'ROLE_ADMIN').save(failOnError: true)
def admin = new User(
username: 'admin',
password:
springSecurityService.encodePassword(password)).save(failOnError: true)
UserRole.create(admin, adminRole, true)
log.warn "Generated admin credentials: admin / $password"
}
}
}
def destroy = {
}
}
```
### Actual Behaviour
On bootstrap phase, the application raises this error:
`java.lang.IllegalArgumentException: Not an entity: class com.example.Role`
Disabling spring boot dev tools the application starts successfully.
Claude Code summary:
java.lang.IllegalArgumentException: Not an entity: class com.example.Role
The IllegalArgumentException: Not an entity: class com.example.Role wasn't
a problem in your Role.groovy/User.groovy/BootStrap.groovy — those are all
correctly written.
It's a compatibility bug between Spring Boot DevTools' restart classloader
and GORM/Hibernate5 on this exact stack: Grails 8.0.0-M5 + Hibernate ORM 5.6.15
+ Spring Boot 4.1.0.
How I confirmed it:
- Reproduced the crash reliably via bootRun against your dev MySQL.
- Proved it wasn't Role-specific — swapping in User.count() first hit the
identical "Not an entity" error, and it also failed from a live HTTP request
long after startup completed, ruling out a boot-order race.
- Isolated it to Criteria-based GORM calls specifically:
Role.count()/Role.list() failed, but Role.get() and raw HQL worked — and
.save() threw a field/getter reflection IllegalArgumentException, the textbook
signature of the same class name being loaded by two different
ClassLoaders.
- Removing spring-boot-devtools from the classpath made count(), list(),
and save() all work immediately (thread name also switched from restartedMain
to plain main, confirming DevTools' restart classloader was the
split).
- Re-verified end-to-end with a clean DB: BootStrap now logs Generated
admin credentials: admin / <uuid> with zero errors.
What I changed:
- build.gradle — commented out developmentOnly
"org.springframework.boot:spring-boot-devtools" with an explanatory comment.
- Everything else (BootStrap, application.groovy, domain classes) is back
to exactly how you had it — my diagnostic edits (temp DiagController, debug
logging, a scoped /diag security rule) were all reverted.
- Cleaned up the one leftover test row I'd accidentally committed to the
role table during diagnosis.
Tradeoff: you lose DevTools' auto-restart/LiveReload during development
until this Grails milestone/Hibernate5 combo is fixed upstream (worth watching
Grails' issue tracker, since 8.0.0-M5 + Spring Boot 4 is very
fresh).
### Steps To Reproduce
Fresh Grails 8.0.0-M5 project created from start.grails.org.
Features:
- spring security core
- database migration
- spring boot devtools as development relaoding
### Environment Information
- Operating System: Windows
- Java JDK: 21
### Example Application
_No response_
### Version
Grails 8.0.0-M5
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]