Daemon task -- UnavailableSecurityManagerException

231 views
Skip to first unread message

Dan Finkelstein

unread,
Apr 20, 2011, 12:17:39 PM4/20/11
to haze...@googlegroups.com
Hi --

In my web application, I am trying to run a daemon task.  This task is run from outside the normal web/servlet processing.

I am attempting to create a subject and bind it to this task like this:

    Subject subject = new Subject.Builder().buildSubject();
   
    ThreadState state = new SubjectThreadState(subject);
    state.bind();
    try {
        // run tasks
    } finally {
        state.clear();
    }

but it throws this:

org.apache.shiro.UnavailableSecurityManagerException: No SecurityManager accessible to the calling code, either bound to the org.apache.shiro.util.ThreadContext or as a vm static singleton.  This is an invalid application configuration.
    at org.apache.shiro.SecurityUtils.getSecurityManager(SecurityUtils.java:123)

when it is building the subject.

I believe I would like Shiro to use the exact, same SecurityManager that all the standard processing uses, which is DefaultWebSecurityManager, but I don't understand how to initialize this "thread" to use it.  I have read through the documentation and have I tried variations of SecurityUtils.setSecurityManger() with no luck. 

Thanks much,
Dan

Mehmet Dogan

unread,
Apr 20, 2011, 2:31:22 PM4/20/11
to haze...@googlegroups.com
Hi Dan, 

I could not get the relation of a Subject and a daemon task. I do not know exactly how Shiro works but I guess Shiro binds a security manager to thread context by a servlet or servlet filter. And if your task (Is this task a distributed task over Hazelcast?) runs outside of servlet context then most probable you should create a security manager or get any from some other context created before  and explicitly bind that into running thread's context.

@mmdogan




--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To post to this group, send email to haze...@googlegroups.com.
To unsubscribe from this group, send email to hazelcast+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/hazelcast?hl=en.

dan

unread,
Apr 20, 2011, 8:08:38 PM4/20/11
to Hazelcast
Please accept my humble apologies -- this post was in error.

Dan

On Apr 20, 11:31 am, Mehmet Dogan <meh...@hazelcast.com> wrote:
> Hi Dan,
>
> I could not get the relation of a Subject and a daemon task. I do not know
> exactly how Shiro works but I guess Shiro binds a security manager to thread
> context by a servlet or servlet filter. And if your task (Is this task a
> distributed task over Hazelcast?) runs outside of servlet context then most
> probable you should create a security manager or get any from some other
> context created before  and explicitly bind that into running thread's
> context.
>
> @mmdogan
>
Reply all
Reply to author
Forward
0 new messages