Replies: 10 comments 6 replies
-
|
As an example of this not working, see: https://github.com/jamesward/hello-embabel This exposes an Embabel agent via Spring Web. When dev tools is on the classpath, the agent is no longer found when using |
Beta Was this translation helpful? Give feedback.
-
|
@jamesward upon restart agent is no longer operational? thank you |
Beta Was this translation helpful? Give feedback.
-
|
Steps to reproduce:
This produces the error: If you comment out the |
Beta Was this translation helpful? Give feedback.
-
|
Thank you, James |
Beta Was this translation helpful? Give feedback.
-
ExperimentExperimented with Shell. please refer to code: ExecutionTo force re-start:
watch for: SummaryCombination of DevTools and Spring Shell works fine, as long as auto-reload gets disabled (see Sharing full problem statement in a separate window. Would you please consider moving this to discussion if you feel that's is proper approach. @jamesward please advise. @johnsonr , @alexheifetz , @poutsma -FYI |
Beta Was this translation helpful? Give feedback.
-
Spring Shell 3.x & Spring Boot DevTools Restart: Technical AnalysisProblem StatementA Spring Boot application using Spring Shell 3.x enters an interactive CLI mode on startup. When Spring Boot DevTools is enabled with automatic restart, modifying any classpath resource triggers a DevTools restart cycle. Observed behavior: Before restart:
After restart:
DevTools logs show restart triggered, but the application does not fully reinitialize Manual termination (CTRL+C) is required to recover. Impact: The interactive shell becomes unusable after any DevTools-triggered restart. Root Cause: Why DevTools Restart Does Not Work1 Spring Shell 3.x blocks the main thread
But because Spring Shell 3.x never releases the main thread, DevTools cannot:
After restart:
No command found for 'OA'
Even when forcing DevTools to reload:
…the shell loop still never reinitializes because DevTools cannot restart the application while the shell loop is blocking. Conclusion: Spring Shell 3.x interactive mode is not compatible with DevTools restart.
Setting: spring.devtools.restart.enabled=false disables only the restart classloader, not DevTools itself. This avoids:
The shell runs once, stays alive, and remains stable. We still have benefits :
We lose only the restart feature — which Spring Shell 3.x cannot support anyway. Options to Fix or Work Around the LimitationOption A — Disable DevTools Restart (Recommended for Spring Shell 3.x)spring.devtools.restart.enabled=false Pros:
Cons:
Option B — Downgrade to Spring Shell 2.xSpring Shell 2.x:
Pros:
Cons:
Option C — Redesign ShellCommand Beans to Make the Shell RestartableThis requires:
Pros:
Cons:
Final RecommendationFor Spring Shell 3.x interactive applications, the correct and stable configuration is: spring.devtools.restart.enabled=false This avoids architectural conflicts between DevTools and the Spring Shell terminal loop, while preserving all other DevTools benefits. If hot reload is a hard requirement, consider: downgrading to Spring Shell 2.x, or implementing a custom restartable shell loop —but these require deliberate architectural changes. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the investigation! I think ultimately we want to:
It sounds like we may need to start with some upstream fixes to DevTools & Spring Shell. Maybe we can get @philwebb to help. Just to confirm, for the non-Spring Shell use cases, is the underlying issue something that has to be fixed upstream or is there something in Embabel that could be fixed? |
Beta Was this translation helpful? Give feedback.
-
|
Thanks James, Option C - is more domain of Spring Shell /DevTools , solution should not be embabel-specific, IMO. we can have demo session if needed for spring team too. |
Beta Was this translation helpful? Give feedback.
-
|
Back to non-shell (web app use case), I'm not sure yet if that is an issue with DevTools or Embabel. Reproduction steps: #1133 (comment) Can you all do more digging on that one as it seems like an issue with how Embabel does something with classloaders? |
Beta Was this translation helpful? Give feedback.
-
|
With regards to "Spring Shell 3.x blocks the main thread", devtools should throw a I suspect the issue is more likely to be with classloaders since that's historically been quite a cause of pain with devtools. If there is something we can improve on the Spring Boot side please open an issue at https://github.com/spring-projects/spring-boot/issues/new |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
It'd be awesome if the shell (or other persistent runners: MCP, custom web API around an agent, etc) supported auto-reload with Spring Dev Tools.
When I tried this something got out-of-whack. (Note: I will try again and grab logs to share)
Beta Was this translation helpful? Give feedback.
All reactions