Prev Next

API / Apache Grails Interview questions

Explain the lifecycle of a request in a Grails application?

A request in Grails passes through several layers built on top of the underlying Spring Boot/servlet stack before a response is generated, with Grails' own conventions handling most of the routing and rendering decisions along the way.

flowchart TD A[Incoming HTTP request] --> B[Servlet container / Spring Boot dispatcher] B --> C[Grails UrlMappings resolves URL to controller/action] C --> D{Custom URL mapping exists?} D -- Yes --> E[Use explicit mapping] D -- No --> F[Use default convention: /controller/action] E --> G[Instantiate/reuse controller, bind params] F --> G G --> H[Any configured interceptors run before the action] H --> I[Controller action executes, typically delegating to services] I --> J{Action returns model / calls render or redirect?} J -- Render view --> K[Resolve matching GSP by convention] K --> L[GSP rendered to HTML] J -- Render JSON/other --> M[Serialize response directly] L --> N[Any configured interceptors run after the action] M --> N N --> O[Response sent to client]

The request first passes through Spring Boot's own dispatching machinery, then Grails' UrlMappings resolve which controller and action should handle it, either via an explicit mapping or the default convention. Before the action itself runs, any configured interceptors get a chance to inspect or short-circuit the request (for things like authentication checks), and after the controller action executes — typically by delegating real work to a service — Grails resolves and renders the matching GSP view (or serializes a direct response for a REST-style action) before interceptors run again on the way out and the final response is sent.

This layered structure is what lets Grails add its own conventions (URL mapping, view resolution, interceptors) cleanly on top of the standard servlet request lifecycle rather than replacing it outright.

At what point in the request lifecycle do configured interceptors first get a chance to run?
What determines which GSP file gets rendered after a controller action completes, when no explicit view is specified?

More Related questions...

What is Apache Grails? What is GORM? What is a Grails domain class? What is a Grails controller? What is a Groovy Server Page (GSP)? What is convention-over-configuration in Grails? What is a dynamic finder in GORM? What is Grails Forge? What is the Grails Wrapper (grailsw)? What is a Grails service? What are the types of environments Grails supports? What is scaffolding in Grails? What is a Grails plugin? Define GORM Data Services? How do you create a new Grails application using Grails Forge? Why did Grails move under the Apache Software Foundation? Why do we use GORM instead of writing raw SQL/JDBC? How does Grails apply convention-over-configuration to map URLs to controllers? What is the difference between Grails 7 and Grails 8? When should you use GORM Data Services instead of dynamic finders? What is the difference between a dynamic finder and a criteria query? What happens when a domain class fails validation in Grails? What is the difference between a Grails controller and a Grails service? Which is better for a new project in 2026: Grails 7 or Grails 8, and why? How can you optimize GORM queries to avoid the N+1 problem? How do you troubleshoot a LazyInitializationException in a Grails application? Explain the lifecycle of a request in a Grails application? Explain the execution flow of a GORM save() call under the hood? Explain the internal working of GORM Data Services? What is the difference between an interceptor and a filter in Grails? Why should you mark long-running database work with @Transactional at the service layer? What is a Grails command object? How does Grails integrate with Spring Security? What is the difference between static and dynamic scaffolding in Grails? How does Grails support internationalization (i18n)? Explain the internal working of Grails' convention-based URL mapping? What is the difference between Grails profiles like "web" and "rest-api"? How do you enforce validation constraints on a Grails domain class? What is the role of the asset-pipeline plugin in Grails? How does Grails support database migrations? Explain the sequence of events when a GSP page is rendered? What is the difference between GORM criteria queries and HQL? How do you configure multi-tenancy in a Grails application with GORM? What is the difference between Grails' component model and Spring Boot's plain REST controller approach? Explain how Grails' dependency injection works with Spring beans? How do you write unit and integration tests for a Grails application? What is the difference between unit tests and integration tests in Grails testing? Explain the internal working of a GORM dynamic finder at runtime? What is the difference between Apache Grails and Ruby on Rails? Explain how GORM's optimistic locking prevents concurrent update conflicts?
Show more question and Answers...


Comments & Discussions