Skip to content
Discussion options

You must be logged in to vote

After coming back to this with a fresh head (and better streamlining ChatGPT 😄 with the right questions), I finally found a clean solution.

The right place to hook in is after the Shiro environment is created by @WebListener org.apache.shiro.ee.listeners.EnvironmentLoaderListener.
Instead of trying to control listener order, the simplest approach is to wait until the WebEnvironment is stored in the ServletContext, and then initialize the VM-level singleton there.

This is mainly needed for background / timer jobs, since they’re not tied to any HTTP request or web context.

Code is simple and clear:

@WebListener
public class ShiroVMSecurityManagerBinder implements ServletContextAttributeList…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@lprimak
Comment options

lprimak Jan 8, 2026
Collaborator

@AndrewG10i
Comment options

@lprimak
Comment options

lprimak Jan 8, 2026
Collaborator

Comment options

You must be logged in to vote
1 reply
@lprimak
Comment options

lprimak Jan 9, 2026
Collaborator

Answer selected by lprimak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants