jamesfredley opened a new pull request, #15541: URL: https://github.com/apache/grails-core/pull/15541
## Summary This PR upgrades Grails Core to **Spring Boot 4.0.5** and **Spring Framework 7.0.6**, bringing major framework updates and compatibility fixes. **This PR uses Groovy 4.0.x and Hibernate 5.6-jakarta, since work on Groovy 5 and Hibernate 7.2 is progressing on other branches.** **This is the minimum amount required for Grails to run on Spring Boot 4 and Hibernate 5.6-jakarta** **Includes merge from 8.0.x branch** (7.0.x/7.1.x merge-ups, PluginDiscovery system, deprecations, new `grails-testing-support-http-client` module, `@CompileStatic` tag lib support, `DatabaseCleanup` annotation inheritance, functional test migrations) ### Key Changes - Upgrade Spring Boot from 3.5.x to 4.0.5 - Upgrade Spring Framework from 6.2.x to 7.0.6 - Update all affected module imports and APIs for compatibility - Add vendored Spring ORM code for removed Hibernate 5 integration classes (Spring 7 dropped Hibernate 5 support) - Remove Spring theme/JSP support (deprecated in Grails 7.1, see #15457) - Update MongoDB properties from `spring.data.mongodb.*` to `spring.mongodb.*` (Spring Boot 4 migration) ## Detailed Change Inventory | Category | Change | Files | |----------|--------|-------| | Vendored Spring ORM code | Spring 7 removed Hibernate 5 ORM integration classes. Vendored HibernateTemplate, HibernateTransactionManager, HibernateOperations, LocalSessionFactoryBean, LocalSessionFactoryBuilder, SessionFactoryUtils, SessionHolder, etc. into grails-data-hibernate5 | 16 new files in `grails-data-hibernate5/core/src/main/java/.../hibernate5/` | | Theme/JSP support removed | Spring 7 removed theme support from DispatcherServlet. Rather than vendoring, theme/JSP support was deprecated in Grails 7.1 and removed here (#15457) | GspAutoConfiguration, GrailsApplicationContext, GrailsWebApplicationContext, AbstractGrailsTagTests, related test files | | Package relocations | Updated imports for 6 autoconfigure classes that moved in Spring Boot 4 | ApplicationClassInjector, GrailsApplicationCompilerAutoConfiguration, ControllersAutoConfiguration, GrailsFilters, MongoDbGormAutoConfiguration | | MongoDB property renames | `spring.data.mongodb.*` to `spring.mongodb.*` | application.yml, StartMongoGrailsIntegrationExtension, MongoDB test specs | | Removed API replacements | SecurityProperties.DEFAULT_FILTER_ORDER replaced with hardcoded -100; AnnotationConfigServletWebApplicationContext replaced with GenericWebApplicationContext; MappedInterceptor.matches(String,PathMatcher) replaced with matches(HttpServletRequest) | GrailsFilters, GrailsApplicationBuilder, UrlMappingsHandlerMapping | | Constructor signature changes | DefaultTransactionStatus now requires 8 params (added transactionName and nested) | TransactionalTransformSpec | | Deprecated method removal | HandlerAdapter.getLastModified() removed from interface | UrlMappingsInfoHandlerAdapter | | LoaderImplementation removed | LoaderImplementation enum removed in Spring Boot 4; related configuration removed | GrailsGradlePlugin, boot-plugin configurations | | Test support updates | MockApplicationContext added getBeanProvider(ParameterizedTypeReference); AbstractGrailsTagTests added static constants for removed theme attributes | MockApplicationContext.java, AbstractGrailsTagTests | ## Breaking Changes in Spring Boot 4 / Spring Framework 7 ### Package Relocations (Spring Boot 4) Spring Boot 4 restructured its autoconfigure modules. The following classes moved: | Class | Old Package | New Package | |-------|-------------|-------------| | `DataSourceAutoConfiguration` | `org.springframework.boot.autoconfigure.jdbc` | `org.springframework.boot.jdbc.autoconfigure` | | `ReactorAutoConfiguration` | `org.springframework.boot.autoconfigure.reactor` | `org.springframework.boot.reactor.autoconfigure` | | `HibernateJpaAutoConfiguration` | `org.springframework.boot.autoconfigure.orm.jpa` | `org.springframework.boot.hibernate.autoconfigure` | | `MongoAutoConfiguration` | `org.springframework.boot.autoconfigure.mongo` | `org.springframework.boot.mongodb.autoconfigure` | | `AnnotationConfigServletWebServerApplicationContext` | `org.springframework.boot.web.servlet.context` | `org.springframework.boot.web.server.servlet.context` | | `BootstrapRegistry` | `org.springframework.boot` | `org.springframework.boot.bootstrap` | | `BootstrapRegistryInitializer` | `org.springframework.boot` | `org.springframework.boot.bootstrap` | | `ConfigurableBootstrapContext` | `org.springframework.boot` | `org.springframework.boot.bootstrap` | ### Property Renames (Spring Boot 4) | Old Property | New Property | |--------------|--------------| | `spring.data.mongodb.host` | `spring.mongodb.host` | | `spring.data.mongodb.port` | `spring.mongodb.port` | | `spring.data.mongodb.uri` | `spring.mongodb.uri` | | `spring.data.mongodb.database` | `spring.mongodb.database` | ### Removed APIs | Removed | Replacement/Fix | |---------|-----------------| | `SecurityProperties.DEFAULT_FILTER_ORDER` | Hardcoded value `-100` in `GrailsFilters` | | `AnnotationConfigServletWebApplicationContext` | Use `GenericWebApplicationContext` for testing | | `DispatcherServlet` theme support | Removed from Grails (deprecated in 7.1, see #15457) | | `MappedInterceptor.matches(String, PathMatcher)` | Use `matches(HttpServletRequest)` | | `HandlerAdapter.getLastModified()` | Method deprecated (removed from interface) | | Spring ORM Hibernate 5 integration classes | Vendored into grails-data-hibernate5 | | `LoaderImplementation` enum | Removed from Spring Boot 4; related Grails configuration removed | ### spring.factories Key Changes (Spring Boot 4) | Old Key | New Key | |---------|---------| | `org.springframework.boot.BootstrapRegistryInitializer` | `org.springframework.boot.bootstrap.BootstrapRegistryInitializer` | ### Constructor Changes (Spring Framework 7) - `DefaultTransactionStatus` now requires 8 parameters (added `transactionName` and `nested`) ## Workarounds | Workaround | Reason | Impact | |------------|--------|--------| | Vendored Spring Hibernate 5 ORM classes into grails-data-hibernate5 | Spring 7 removed Hibernate 5 integration | Required only for the Hibernate 5.6-jakarta path. Goes away when apps migrate to Hibernate 7.2 | | Hardcoded DEFAULT_FILTER_ORDER = -100 in GrailsFilters | SecurityProperties.DEFAULT_FILTER_ORDER removed | Fragile if Spring Security changes the default. Should use Spring Security's constant when security plugin is updated | ## Files Changed ### Core Module Updates - `ApplicationClassInjector.groovy` - Updated excluded auto-configuration class paths - `GrailsApplicationCompilerAutoConfiguration.java` - Updated DataSourceAutoConfiguration path - `ControllersAutoConfiguration.java` - Import reorganization for new packages - `GrailsFilters.java` - Removed SecurityProperties dependency, added DEFAULT_FILTER_ORDER constant - `GrailsGradlePlugin.groovy` - Removed LoaderImplementation references - `GrailsEnvironmentPostProcessor.java` - Updated bootstrap API imports for Spring Boot 4 package relocation - `GrailsBootstrapRegistryInitializer.java` - Updated bootstrap API imports for Spring Boot 4 package relocation - `spring.factories` - Updated BootstrapRegistryInitializer key for Spring Boot 4 package relocation ### GSP / Theme Removal - `GspAutoConfiguration.java` - Removed theme resolver configuration - `GrailsApplicationContext.java` - Removed ThemeSource field, onRefresh(), getTheme() - `GrailsWebApplicationContext.java` - Removed ThemeSource import and interface (removed in Spring Framework 7) - Theme/JSP support removed per #15457 (deprecated in Grails 7.1) ### Testing Support - `GrailsApplicationBuilder.groovy` - Use GenericWebApplicationContext instead of AnnotationConfigServletWebApplicationContext; integrated 8.0.x PluginDiscovery system - `MockApplicationContext.java` - Added `getBeanProvider(ParameterizedTypeReference)` method - `AbstractGrailsTagTests.groovy` - Added static constants for removed theme attributes - `TransactionalTransformSpec.groovy` - Updated DefaultTransactionStatus constructor calls - `DefaultUrlCreatorTests.groovy` - Fixed ambiguous method overloading for setCharacterEncoding ### URL Mappings - `UrlMappingsHandlerMapping.groovy` - Updated MappedInterceptor.matches() call signature - `UrlMappingsInfoHandlerAdapter.groovy` - Deprecated getLastModified() method ### MongoDB Support - `MongoDbGormAutoConfiguration.groovy` - Updated MongoAutoConfiguration import path - `MongoDbGormAutoConfigurationSpec.groovy` - Updated property names for Spring Boot 4 - `MongoDbGormAutoConfigureWithGeoSpacialSpec.groovy` - Updated property names for Spring Boot 4 - `StartMongoGrailsIntegrationExtension.groovy` - Updated spring.mongodb.uri property - `mongodb/base/application.yml` - Updated spring.mongodb.host/port properties ### Build Configuration - `grails-data-hibernate5/boot-plugin/build.gradle` - Added spring-boot-jdbc and spring-boot-hibernate test dependencies - `grails-test-examples/hibernate5/spring-boot-hibernate/build.gradle` - Added spring-boot-hibernate for package relocation ## Test Status ### CI Build Status All CI test suites pass when Apache repository (repository.apache.org) is reachable: - Core tests (`./gradlew build -PonlyCoreTests`) - Functional tests (`./gradlew build -PonlyFunctionalTests`) - Hibernate5 tests (`./gradlew build -PonlyHibernate5Tests`) - MongoDB tests (`./gradlew build -PonlyMongodbTests`) **Note:** Some CI runs may fail due to transient connectivity issues with repository.apache.org (37.27.138.133). These are infrastructure issues, not test failures. ### Known Build Issues (WIP) - `ApplicationClassInjectorSpec` - test expects old autoconfigure package path ### Disabled Tests (External Plugin Incompatibilities) The following test modules have their `integrationTest` task disabled at the build level, since the Spring Security auto-configuration failure prevents the ApplicationContext from loading (cascading to all tests in the module): | Module | Plugin/Library | Root Cause | Action Needed | |--------|----------------|------------|---------------| | `app1` | Spring Security 7.0.1-SNAPSHOT | `ReflectionUtils.getApplication()` removed in Spring Boot 4 | Update grails-spring-security plugin | | `app3` | Spring Security | Same as above | Same | | `exploded` | Spring Security | Same as above | Same | | `plugins/exploded` | Spring Security | Same as above | Same | | `mongodb/test-data-service` | Spring Security | Same as above | Same | | `gsp-sitemesh3` | SiteMesh3 | Decorator/layout not compatible with Spring Framework 7 | Update SiteMesh3 integration | Additionally, the following individual tests are disabled: | Test | Reason | |------|--------| | `gsp-layout/GrailsLayoutSpec."jsp demo"` | JSP/theme support removed in Spring Framework 7 (see #15457) | | `issue-views-182/CustomErrorSpec` | JSON Views error handling response times out | | `RenderMethodTests.testRenderFile` (`@PendingFeature`) | MockHttpServletResponse behavior changed in Spring Framework 7 | ## Open Decisions | Decision | Context | Options | |----------|---------|---------| | SiteMesh3 | SiteMesh3 is incompatible with Spring 7 | (a) Request update to SiteMesh3, (b) Replace with Grails-native layout mechanism | | Micronaut Spring | Current `micronautPlatformVersion=4.9.2` pulls Micronaut Spring 5.x (targets Spring Boot 3.x) | (a) Pin `micronaut-spring-boot-starter:6.0.0-M1` for Spring Boot 4 compat, (b) Wait for Micronaut 5 stable release | ## Remaining Work - Update `ApplicationClassInjectorSpec` for new autoconfigure package paths - Update grails-spring-security plugin for `ReflectionUtils.getApplication()` removal - Fix SiteMesh3 decorator integration for Spring Framework 7 - Address JSON Views error handling timeout - Rework Bean Builder - Spring 7 drops XML configuration support (#14915); the current BeanBuilder is backed by XML; needs programmatic bean registration - Evaluate Micronaut Spring 6.0.0-M1 for Spring Boot 4 Micronaut integration ## Action Required The following external plugins/libraries need updates for full Spring Boot 4 compatibility: 1. **grails-spring-security** - Update ReflectionUtils for Spring Boot 4 API changes 2. **SiteMesh3** - Update decorator integration for Spring Framework 7 -- 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]
