Hi,
after some more testing, it seems that the NullPointerException occurs
everytime when an annotated method has one or more parameters (annotating the
parameter or not seems to be irrelevant).
Removing the method-parameter directly prevents Shiro throwing the
NullPointerException...
Is this an known bug of AspectJ Shiro authorization package or should I fill a
JIRA ticket?
Greets,
Christian
> Hi there,
>
> using Shiro along with "JBoss RESTeasy" for fast rest-based web-application
> development I'm running into some mysterious NullPointerExceptions :-/
>
> Example-Code:
> ----------
> @POST
> @Path("/{contactType}")
> @Produces(MediaType.APPLICATION_JSON)
> @Consumes(MediaType.APPLICATION_JSON)
> @RequiresUser
> public static Response createContact(@PathParam("contactType") String
> contactType, String request)
> {
> // do something
> }
> ----------
>
> Sending an POST-Request to the site produces the following Exception:
> ----------
> […]
> Caused by: java.lang.NullPointerException
> at
>org.apache.shiro.aop.DefaultAnnotationResolver.getAnnotation(DefaultAnnotationResolver.java:62)
> at
>org.apache.shiro.aop.AnnotationMethodInterceptor.getAnnotation(AnnotationMethodInterceptor.java:148)
> at
>org.apache.shiro.aop.AnnotationMethodInterceptor.supports(AnnotationMethodInterceptor.java:134)
> at
>org.apache.shiro.authz.aop.AnnotationsAuthorizingMethodInterceptor.assertAuthorized(AnnotationsAuthorizingMethodInterceptor.java:99)
> at
>org.apache.shiro.authz.aop.AuthorizingMethodInterceptor.invoke(AuthorizingMethodInterceptor.java:38)
> at
>org.apache.shiro.aspectj.AspectjAnnotationsAuthorizingMethodInterceptor.performBeforeInterception(AspectjAnnotationsAuthorizingMethodInterceptor.java:61)
> at
>org.apache.shiro.aspectj.ShiroAnnotationAuthorizingAspect.executeAnnotatedMethod(ShiroAnnotationAuthorizingAspect.java:52)
> ----------
>
> Looking into org.apache.shiro.aop.DefaultAnnotationResolver at line 62:
>
> return annotation == null ? mi.getThis().getClass().getAnnotation(clazz) : annotation;
>
> So the only possible source of the NullPointer seems to be "mi.getThis()" for
> me…
>
> Any suggestions how to avoid and/or solve this?
>
>
> Greets,
>
> Christian Scharr