How to get SecurityManager once Jakarta EE EnvironmentLoaderListener (@WebListener) triggered and Shiro environment initialized? #2445
-
|
Hi, When running a Jakarta EE application on Payara 6.x (latest), I observe that However, I do not see a straightforward way to do this, since the container invokes Shiro’s EnvironmentLoaderListener last in the startup sequence. The task itself is scheduled via Hazelcast and therefore executes outside of the Jakarta EE context. As a result, I cannot What would be an appropriate solution for this scenario? P.S. I have already tried multiple approaches and workarounds, but each has run into limitations that prevent achieving the desired behavior. P.P.S. Thanks for enabling discussion here on GitHub - I was never able to make effective use of the mailing user groups. :) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
|
Hi, If you look at https://shiro.apache.org/jakarta-ee.html, you will see a section I am assuming you can write another filter to plug into initialization process that way. |
Beta Was this translation helpful? Give feedback.
-
|
In my case it is rather about Listener What I have tried:
Any ideas? Thanks! |
Beta Was this translation helpful? Give feedback.
-
|
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 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: @lprimak, дякую за швидкі відповіді та чудовий проект! ;) |
Beta Was this translation helpful? Give feedback.
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: