Quick revision
The short answer
The main risks are that Spring Boot 4 assumes one application context built with auto-configuration and optionally AOT, while the product relies on child contexts and custom class loaders that Boot does not focus on; that post-processors, events and proxies may behave differently across the parent and child contexts; and that customer plugins still use javax packages and old Spring APIs. I would redesign towards a narrow, versioned plugin API loaded with ServiceLoader, or plugins in separate processes, and prove the result with real customer plugins before release.
What to remember
In this answer, we assessed moving a plugin system built on child contexts and custom class loaders to Spring Boot 4. The risks sit in auto-configuration, AOT and logging, which Boot designs around one context; in post-processors, events and proxies that must be rechecked across parent and child contexts; and in the javax to jakarta change inside code that customers own. The redesign narrows the contract to a small versioned plugin API loaded with ServiceLoader, with separate processes for plugins that need strong isolation, delivered through a bridge release and proven with real customer plugins.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
The main risks are that Spring Boot 4 assumes one application context built with auto-configuration and optionally AOT, while the product relies on child contexts and custom class loaders that Boot does not focus on; that post-processors, events and proxies may behave differently across the parent and child contexts; and that customer plugins still use javax packages and old Spring APIs. I would redesign towards a narrow, versioned plugin API loaded with ServiceLoader, or plugins in separate processes, and prove the result with real customer plugins before release.
Why this question is asked
Plugin systems built on Spring a decade ago were clever: every customer plugin got its own child application context and class loader, and could use the full power of Spring. The trouble is that the plugin contract was, in effect, the whole Spring Framework. Moving to Spring Boot 4 changes that contract underneath code the vendor does not own. Interviewers ask this scenario to see how a senior engineer reasons about risk, compatibility and customer impact, not only about framework features. In this answer, we will recap how the current design works, list the risks one area at a time, look at redesign options and what each costs, and finish with a migration and testing plan.
1A Quick Recap of the Current Design
Each plugin ships as a jar. The product creates a new class loader for it, a component that finds and loads classes, here with the product's own class loader as parent, so the plugin can see product classes but its own classes stay separate. Then the product creates a child application context, the Spring container, with the main context as parent, and registers the plugin's configuration classes in it. Plugin beans can inject product beans from the parent, and the product finds plugin beans by looking them up in the child.
This means a plugin can use any Spring feature: @Transactional, @Scheduled, event listeners, its own aspects. It also means a plugin can depend on internal behaviour of Spring 5 that nobody promised to keep.
- Plugin A context + class loadercustomer code, uses Spring APIs directly
- Plugin B context + class loaderanother customer, maybe another Spring style
- Main product contextbuilt by hand, shared services, transaction manager
- Spring Framework 5, javax APIsthe real contract the plugins depend on
4 layers, from the top down. Step through them one at a time.
2Risks in the Framework Itself
Spring Boot 4 builds on Spring Framework 7, requires Java 17 or later and moves to Jakarta EE 11. Boot's auto-configuration is designed for one main context. Conditions such as @ConditionalOnMissingBean evaluate in the context where the auto-configuration runs, so if we let auto-configuration run in plugin contexts, a plugin may get a second ObjectMapper, a second set of metrics or even a second web server, and if we do not, plugins lose features they used to get from the parent's manual configuration.
AOT processing, the build-time step that analyses bean definitions to produce faster startup and native images, assumes the set of beans is known when we build the product. Plugins discovered at runtime from a folder cannot be part of that analysis, so for this product AOT and native images are probably out of scope for plugin contexts, and we should say so explicitly. Logging is another quiet risk: Boot initialises one logging system per JVM, and plugins that bring their own Logback or Log4j configuration on their own class loader can clash or log nowhere.
3Risks Across Parent and Child Contexts
We must check that the behaviour plugins rely on still holds. BeanPostProcessors work per context, so transaction proxies, @Async and aspects only apply in a plugin context if that context registers them; if the old product registered them by copying configuration into each child, we must confirm the new code still does. Events published in a plugin context reach the parent, but parent events do not reach plugins, and some plugins may have depended on a custom multicaster that worked around this.
Proxies are a third area. Spring Boot defaults to class-based proxies, which subclass the bean, while an old XML setup may have used JDK interface proxies. A plugin that casts a product bean to an interface, or a product that casts a plugin bean to its class, can fail with ClassCastException after the switch. Class loaders make this worse: the same interface loaded by two class loaders is two different types, so a type check that used to pass can fail.
4The javax to jakarta Change
Jakarta EE 9 renamed the javax.* enterprise packages to jakarta.*, for example javax.persistence to jakarta.persistence and javax.servlet to jakarta.servlet. Spring Framework 6 and 7 support only the jakarta names. Any plugin that imports javax.persistence.Entity or javax.annotation.PostConstruct will no longer compile against the new product, and an already built plugin jar will fail at runtime with NoClassDefFoundError or, worse, will load but have its annotations silently ignored.
The difficulty is that customers own this code. We cannot fix it for them, and they cannot all upgrade on our release date. So the plan must include a migration guide, a tool or recipe for the rename (OpenRewrite has recipes for it), a compatibility check at plugin load time that reports which classes reference javax, and a support window for the old product line.
5Redesign Options and What Each Costs
The deeper lesson is that the plugin contract should not be the entire framework. I would compare three directions.
| Option | Isolation | Cost |
|---|---|---|
| Keep child contexts, upgrade them | weak: shares framework internals | lowest effort now, same fragility next upgrade |
Narrow plugin API + ServiceLoader | good: plugins see only API types | API design work, customers rewrite once |
| Plugins in separate processes | strong: own JVM, own versions | network calls, deployment, latency |
6Choosing and Planning the Migration
I would define a small plugin API module, for example interfaces such as PricingPlugin and PluginContext, versioned on its own with semantic versioning and with no Spring types in its signatures. The product discovers implementations with java.util.ServiceLoader, which reads META-INF/services files in each plugin jar, and calls them through the API only. Inside the product, a thin Spring adapter turns each loaded plugin into a bean, so product code keeps using injection. Plugins that truly need heavy isolation, or that come from untrusted parties, run as separate processes behind the same API over HTTP or gRPC.
Because customers need time, I would ship a bridge release that supports both the old child context loading and the new API, with warnings for plugins on the old path, then remove the old path in a later major version with clear release notes. Before release, we test with real customer plugins, collected under agreement or run by customers in a preview program, not only with our own samples, because the risky behaviour lives in code we have never seen.
7Follow-up questions
Why not keep the child contexts and just upgrade?
It is the cheapest path today and may be the right short-term step for a bridge release. But it keeps the root problem: customers depend on framework internals, so every future Spring or Boot upgrade carries the same risk and the same coordination with every customer. A narrow API pays its cost once and then lets the product upgrade Spring without breaking plugins.
How would you find out what customer plugins actually use?
Ask for or collect plugin jars under agreement and scan their bytecode with a tool such as jdeps or a small ASM scanner that lists every referenced package and Spring class. The result shows how many plugins use javax packages, which Spring APIs they touch and which internal product classes they reach into. Those numbers decide the size of the migration and which parts of the old behaviour the bridge release must keep.
What would you test before release?
Load every collected customer plugin into the new product in CI, run each plugin's own tests if they exist, and run end-to-end scenarios that exercise transactions, events and scheduled jobs across the plugin boundary. We should also test memory and class loader leaks by loading and unloading plugins many times, because a child context that is not closed properly keeps its whole class loader alive.
8Conclusion
In this answer, we assessed moving a plugin system built on child contexts and custom class loaders to Spring Boot 4. The risks sit in auto-configuration, AOT and logging, which Boot designs around one context; in post-processors, events and proxies that must be rechecked across parent and child contexts; and in the javax to jakarta change inside code that customers own. The redesign narrows the contract to a small versioned plugin API loaded with ServiceLoader, with separate processes for plugins that need strong isolation, delivered through a bridge release and proven with real customer plugins.
Open with
I would start by recognising that today the plugin contract is effectively the whole Spring Framework, because each plugin gets its own child context and class loader and can use any Spring feature.
Then, if they want more
Spring Boot 4 changes that contract. The first set of risks is in Boot itself: auto-configuration and AOT assume one context whose beans are known at build time, so plugins found at runtime cannot be AOT processed, and logging is initialised once per JVM, which clashes with plugins bringing their own configuration.
The second set is across contexts: post-processors are per context, so I must confirm that transactions, async and aspects still get registered in plugin contexts, events still flow only from child to parent, and the switch to class-based proxies or duplicate classes across class loaders can cause ClassCastExceptions.
The third is the javax to jakarta rename, which breaks plugin code that customers own, so we need a migration guide, an OpenRewrite recipe and a load-time check.
For the redesign, I would define a small versioned plugin API with no Spring types, discover implementations with ServiceLoader, adapt them into beans inside the product, and run untrusted or heavy plugins in separate processes. I would ship a bridge release supporting both paths, and before release run real customer plugins in CI, not just our own samples.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Spring Boot 4, Jakarta EE 11, Jakarta EE 9, Java 17
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Framework reference, Core technologies
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "A product built on Spring a decade ago loads customer plugins into child application...": https://scrivio-interview-library.netlify.app/spring-boot/ioc-container/d44ab1e004/