You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by "jason.hue" <ja...@yahoo.com> on 2012/05/19 00:53:50 UTC
UnavailableSecurityManagerException for spring's init-method ( DAO
call )
i struggle for the error quite some time already.
i use init-method via spring's bean for DAO call.
The error missing if remove the spring's init-method or remove the DAO call.
I have few other spring's bean with init-method but do not encounter the
error UnavailableSecurityManagerException.
I do have LifecycleBeanPostProcessor configured in applicationContext.xml.
If base on the api ,
http://shiro.apache.org/static/current/apidocs/org/apache/shiro/spring/LifecycleBeanPostProcessor.html
It warning not to use the init-method with spring's bean. May i know it's
really matter ?
Basically what i want to achieve is call to DAO after bean initialization
but somehow it give me the error UnavailableSecurityManagerException.
The error due to thread taken by initialization ? And the call to DAO is
another thread ?
http://shiro-user.582556.n2.nabble.com/file/n7566226/init-method.txt
init-method.txt is the init () method. I try to use
SecurityUtils.getSubject() to get obtain the subject and then tie to the
initialization thread and do a call to DAO but SecurityUtils.getSubject()
return me a null value. I have no idea how to solve the problem.
It will be much appreciate if some one provide me some advice / suggestion .
Thanks .
Jason Hue
--
View this message in context: http://shiro-user.582556.n2.nabble.com/UnavailableSecurityManagerException-for-spring-s-init-method-DAO-call-tp7566226.html
Sent from the Shiro User mailing list archive at Nabble.com.
Re: UnavailableSecurityManagerException for spring's init-method (
DAO call )
Posted by Les Hazlewood <lh...@apache.org>.
SecurityUtils.getSubject() works best when a subject has been placed
on the thread (e.g. during a request, executor invocation, or remote
method invocation).
If you need a subject during thread execution, and that execution was
not triggered as a result of a request, you will need to first build
the Subject instance and then bind it to the thread.
Read the 'Custom Subject Instances' section here:
http://shiro.apache.org/subject.html
Use the Subject.Builder to create a subject:
Subject subject = new Subject.Builder(shiroSecurityManager).... .buildSubject();
//execute the thread logic:
subject.execute( new Callable() { ...
//call SecurityUtils.getSubject() anywhere in this call stack, and
it will be fine
});
HTH,
--
Les Hazlewood
CTO, Stormpath | http://stormpath.com | 888.391.5282
twitter: @lhazlewood | http://twitter.com/lhazlewood
blog: http://leshazlewood.com
stormpath blog: http://www.stormpath.com/blog
On Fri, May 18, 2012 at 3:53 PM, jason.hue <ja...@yahoo.com> wrote:
> i struggle for the error quite some time already.
>
> i use init-method via spring's bean for DAO call.
> The error missing if remove the spring's init-method or remove the DAO call.
>
> I have few other spring's bean with init-method but do not encounter the
> error UnavailableSecurityManagerException.
> I do have LifecycleBeanPostProcessor configured in applicationContext.xml.
> If base on the api ,
> http://shiro.apache.org/static/current/apidocs/org/apache/shiro/spring/LifecycleBeanPostProcessor.html
> It warning not to use the init-method with spring's bean. May i know it's
> really matter ?
>
> Basically what i want to achieve is call to DAO after bean initialization
> but somehow it give me the error UnavailableSecurityManagerException.
> The error due to thread taken by initialization ? And the call to DAO is
> another thread ?
>
> http://shiro-user.582556.n2.nabble.com/file/n7566226/init-method.txt
> init-method.txt is the init () method. I try to use
> SecurityUtils.getSubject() to get obtain the subject and then tie to the
> initialization thread and do a call to DAO but SecurityUtils.getSubject()
> return me a null value. I have no idea how to solve the problem.
>
> It will be much appreciate if some one provide me some advice / suggestion .
> Thanks .
>
> Jason Hue
>
>
> --
> View this message in context: http://shiro-user.582556.n2.nabble.com/UnavailableSecurityManagerException-for-spring-s-init-method-DAO-call-tp7566226.html
> Sent from the Shiro User mailing list archive at Nabble.com.