[
https://issues.apache.org/jira/browse/SHIRO-352?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13239393#comment-13239393
]
Bryan Turner commented on SHIRO-352:
------------------------------------
Matt,
Is {{Processor}} an interface, or a class? What does your proxying
configuration in Spring look like? By default, Spring proxies classes by their
interfaces, not their implementations. If commenting out the annotation changes
something, that suggests the underlying cause is related to how the bean is
being proxied. If you inspect the actual object returned at runtime, when you
use the bean name and get the {{Processor}} both with and without the
annotation present, do you see a difference in the object instance you receive?
It's unlikely this is a Shiro bug; it's more likely to be related to Spring
configuration. Excerpts from your Spring configuration and information about
the runtime types you see when retrieving the bean should both be helpful in
resolving the issue.
Hope this helps!
> Shiro annotations with @Component and getBean(Type)
> ---------------------------------------------------
>
> Key: SHIRO-352
> URL: https://issues.apache.org/jira/browse/SHIRO-352
> Project: Shiro
> Issue Type: Bug
> Components: Integration: Spring
> Affects Versions: 1.2.0
> Environment: Linux, Spring, Java
> Reporter: Matt Friedman
>
> I have a bean where I'd like to annotate one of the methods with the
> @RequiresAuthentication annotation.
> When using the @RequiresAuthentication annotation and calling
> applicationContext.getBean(Class<?>) spring does not find my bean. Commenting
> out @RequiresAuthentication allows spring to find the bean.
> Using the string name of the bean instead of the type (i.e.
> applicationContext.getBean(String)) does work.
> // this causes spring to be unable to find the bean when using
> @RequiresAuthentication
> Class<? extends Processor> processorType = command.getProcessorType();
> Processor processor = applicationContext.getBean(processorType);
> // However this works:
> Processor processor = applicationContext.getBean(processorStringName);
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira