I'm upgrading a Grails 6 project to Grails 7. The...
# questions
m
I'm upgrading a Grails 6 project to Grails 7. The project has a few interceptors. Interceptor properties such as matchAll(), request/response and HIGHEST_PRECEDENCE cannot be resolved for some reason and compiling the project fails. I found a static import to fix HIGHEST_PRECEDENCE, but I haven't yet found a solution for other properties such as matchAll() and request/response. I'm using the latest stable version of IntelliJ Ultimate (2025.2.4) and the latest version of the Grails plugin available (252.23892.360). Any advice on upgrading the interceptors (and Grails in general) would be appreciated. I posted this question on Stackoverflow, but let me know if there is a more appropriate place to ask questions now that the project has moved to Apache. https://stackoverflow.com/questions/79802203/grails-7-interceptor-properties-not-working
u
In Grails 7, interceptor methods like
matchAll()
, and properties like
request
and
response
, are still available, but you must ensure your interceptor classes implement the
grails.artefact.Interceptor
trait, which provides these methods and properties. If you are missing imports or your IDE cannot resolve them, check that your project dependencies include
org.apache.grails:grails-interceptors
and that your source files are in the correct location (typically
grails-app/controllers
or
grails-app/interceptors
). For
HIGHEST_PRECEDENCE
, a static import from
org.springframework.core.Ordered
is required. For
matchAll()
, ensure your constructor calls it, and for `request`/`response`, confirm your class is recognized as an interceptor artifact so the trait is applied. See Grails Interceptor docs and API reference. For community support, the best places are the Grails Slack, the Grails mailing list, and GitHub Discussions on the Grails Core repository. Stack Overflow is still used, but the official channels are more active since the move to Apache. Would you like more detail on resolving these specific issues or on the upgrade process in general? Sources: - Grails Interceptor docs - Grails Interceptor API 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
u
A message from kapa.ai
u
Upgrading interceptors from Grails 6 to Grails 7 can present some challenges due to changes in package names, dependency coordinates, and possibly some API adjustments. Here’s guidance based on the official upgrade documentation and API references: ### 1. Static Imports for Constants You already found that
HIGHEST_PRECEDENCE
now requires a static import. This is expected, as Grails 7 has moved many classes and constants to new packages under
org.apache.grails
. Make sure you’re importing from the correct package, for example:
Copy code
groovy import static org.grails.datastore.mapping.core.order.OrderedComparator.HIGHEST_PRECEDENCE
or
Copy code
groovy import static org.springframework.core.Ordered.HIGHEST_PRECEDENCE
depending on your use case and what is available in your classpath. ### 2. Interceptor Methods:
matchAll()
,
match()
, etc.
The
matchAll()
and
match()
methods are not properties but methods provided by the [Interceptor trait](https://grails.apache.org/docs/latest/api/grails/artefact/Interceptor.html). Make sure your interceptor class is defined correctly and that you are not trying to use these as properties. For example:
Copy code
groovy class MyInterceptor {     MyInterceptor() {         matchAll()         // or         match(controller: 'book', action: 'show')     }     // ... }
If these methods are not being resolved, double-check: - Your imports and classpath (ensure you are using Grails 7 dependencies and not mixing with older Grails 6 or 5 artifacts). - That your IDE has re-indexed and re-imported the Gradle project after the upgrade. ### 3. Request/Response Properties The
request
and
response
objects should still be available in interceptors, as they are part of the web context. If they are not being resolved: - Ensure your interceptor is in the correct package and is being recognized as a Grails artefact. - Try a clean build (
./gradlew clean build
) and re-import the project in IntelliJ. ### 4. IDE Issues There are known issues with IntelliJ IDEA and Grails 7 support, especially around code resolution and ambiguous method calls. The Grails team is tracking these issues and recommends using the latest EAP versions of IntelliJ and the Grails plugin. See the [IntelliJ - Better IDE Support issue](https://github.com/apache/grails-core/issues/13910) for details and workarounds. Sometimes, invalidating caches and restarting IntelliJ can help. ### 5. General Upgrade Advice - Update all dependencies: Use only Grails 7-compatible plugins and dependencies. The group IDs have changed to
org.apache.grails
for core artifacts. See the [upgrade guide](https://grails.apache.org/docs/latest/guide/upgrading.html#upgrading60x) for details. - Java 17 baseline: Grails 7 requires Java 17 as the minimum version. - Groovy 4 baseline: Grails 7 uses Groovy 4.0.28. - Use the Grails BOM: Let the Grails Bill of Materials manage your dependency versions to avoid conflicts. - Compare with a fresh app: Generate a new Grails 7 app using [Grails Forge](https://start.grails.org) and compare your project structure and configuration to spot differences and required changes. - Plugin compatibility: All plugins must be Grails 7 compatible. Many plugins require updates due to the move to Apache and the Javax-to-Jakarta transition. ### 6. Where to Ask Questions Now that Grails is an Apache project, the best places to ask questions are: - [Grails GitHub Discussions](https://github.com/apache/grails-core/discussions) - [Grails Slack Community](https://grails-slack.cfapps.io/) - [Grails Users Mailing List](https://lists.apache.org/list.html?users@grails.apache.org) Stack Overflow is still used, but the above are more directly monitored by the core team and community. --- Summary: - Use correct static imports for constants. - Ensure you are using methods (
matchAll()
,
match()
) in the constructor, not as properties. - Clean and re-import your project in IntelliJ. - Use only Grails 7-compatible dependencies and plugins. - Refer to the [official upgrade guide](https://grails.apache.org/docs/latest/guide/upgrading.html#upgrading60x) for detailed steps. - For support, use GitHub Discussions, Slack, or the mailing list. If you continue to have issues with method/property resolution, it is likely an IDE indexing or dependency misconfiguration problem, especially given the known IntelliJ issues with Grails 7. Try the latest plugin, and if problems persist, report them on the [Grails GitHub issue tracker](https://github.com/apache/grails-core/issues) with a minimal reproducible example. --- References: - [Grails 7 Upgrade Guide](https://grails.apache.org/docs/latest/guide/upgrading.html#upgrading60x) - [IntelliJ IDE Support Issues](https://github.com/apache/grails-core/issues/13910) - [Interceptor API](https://grails.apache.org/docs/latest/api/grails/artefact/Interceptor.html) - [Grails 7 Release Announcement](https://grails.apache.org/blog/2025-10-18-introducing-grails-7.html)
u
An alternative approach to resolving issues with interceptor properties during the upgrade to Grails 7 is to leverage the Grails CLI to regenerate interceptors and ensure proper configuration. According to [Grails Interceptor documentation](https://docs.grails.org/latest/guide/theWebLayer.html#definingInterceptors), you can use the
grails create-interceptor
command to create new interceptors that are correctly configured for Grails 7. This ensures that the necessary traits and methods, such as
matchAll()
and `request`/`response`, are properly applied. Additionally, if you encounter issues with
matchAll()
or other methods, you can explicitly define matching rules using the
match()
method with named arguments like
controller
,
action
, or
uri
. This approach is detailed in [Defining Interceptors](https://docs.grails.org/latest/guide/theWebLayer.html#definingInterceptors), and it allows for precise control over request matching without relying solely on
matchAll()
. For broader compatibility and to address potential dependency issues, ensure that your project uses the latest versions of Grails plugins and dependencies compatible with Grails 7. If you suspect IntelliJ or plugin-related issues, try clearing caches and re-importing the project to ensure proper resolution of Grails artifacts. This approach emphasizes regenerating interceptors and explicitly defining matching rules, which can help avoid reliance on potentially deprecated or misconfigured methods. Sources: - [Grails Interceptor documentation](https://docs.grails.org/latest/guide/theWebLayer.html#definingInterceptors) - [Defining Interceptors](https://docs.grails.org/latest/guide/theWebLayer.html#definingInterceptors)
m
The build.gradle file was missing the following dependency. The interceptors are compiling now.
implementation "org.apache.grails:grails-interceptors"