Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] AspectJ NPE in Java15AnnotationFinder

Hi Brad,

Haven't heard from you in a long time!

I did a bit of digging and actually wrote up an explanation of this
issue a couple of years ago in
http://jira.springframework.org/browse/SPR-4390

>1) What are the exact circumstances that cause this problem to occur?  I am
> trying to determine why the application has no problem when running without
> the monitoring product, but experiences the failure when the monitor is installed.
> There must be some subtle change to the environment that is exposing
> this problem, but I can't put my finger on what it is.

The problem relates to the existence of class with the same name in
two different places.  In the case I investigated it was JAXB related.
 The type javax.xml.bind.JAXBContext was in two places - it was in a
jar on the classpath when the app was running, but also it was shipped
as part of the core JDK (java6).  AspectJ load time weaving uses a
couple of different mechanisms to discover types.  When the bug occurs
we had found both versions because we used different routes.  This put
us in a situation where we iterate through the Java6 version of
JAXBContext and for each member ask for the annotations - the 'asking
for the annotations' was being done against the other version.  As the
Java6 version included methods that did not exist in the older version
on the regular classpath, we got an NPE when asking for annotations on
those members.  The fix was to be consistent in how we look things up.

So it would sound like using the monitoring product introduces a
dependency (some new jar) which already exists as part of the target
VM, and they differ like the JAXB class did.

I don't know how many dependencies you introduce.  If you like I can
could create you a patch for the AspectJ you are using that will do
what I did in SPR-4390 (which prints the name of the offending method
and defining type), or you could do a quick test run with a more up to
date AspectJ which includes the diagnostics by default.

> 2) One possible solution is to have the customer upgrade to AspectJ 1.6,
> where it looks like this problem is fixed.  However, I am concerned about compatibility with Spring (not sure
> what release the customer is running).  Are there any known issues with
> attempting this upgrade?

Worth checking what version of Spring they are using.  Spring is
usually pretty good at staying as up to date as possible and I think
Spring Framework 2.5.X and 3.0.3 use AspectJ 1.6.8.

I am not aware of any incompatibilities, but APIs do change so there
might be *something* I've done that affects jumping right to 1.6.8.
If I recall correctly you were using the WeavingClassLoader or
something around that in the monitoring code - I know those APIs have
changed a little bit which could affect the monitor code itself.

Just fyi, not sure you are still using AspectJ in your latest versions
of the monitoring code, but the last few point of releases of 1.6.X
have amazing changes with respect to performance and memory usage:
http://www.eclipse.org/aspectj/doc/released/README-167.html

cheers,
Andy

On 16 June 2010 13:14, Brad Winslow <winslowa@xxxxxxxxxx> wrote:
>
> A customer of our Java/J2EE monitoring product is also using the Spring
> Framework with AOP, and is getting
> the following exception when our product is installed:
>
> Caused by: java.lang.NullPointerException
>  at
> org.aspectj.weaver.reflect.Java15AnnotationFinder.getAnnotations(Java15AnnotationFinder.java:109)
>  at
> org.aspectj.weaver.reflect.ReflectionBasedResolvedMemberImpl.unpackAnnotations(ReflectionBasedResolvedMemberImpl.java:174)
>  at
> org.aspectj.weaver.reflect.ReflectionBasedResolvedMemberImpl.hasAnnotation(ReflectionBasedResolvedMemberImpl.java:158)
>  at
> org.aspectj.weaver.patterns.ExactAnnotationTypePattern.matches(ExactAnnotationTypePattern.java:82)
>  at
> org.aspectj.weaver.patterns.AnnotationPointcut.matchInternal(AnnotationPointcut.java:151)
>  at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:146)
>  at
> org.aspectj.weaver.internal.tools.PointcutExpressionImpl.getShadowMatch(PointcutExpressionImpl.java:235)
>  at
> org.aspectj.weaver.internal.tools.PointcutExpressionImpl.matchesExecution(PointcutExpressionImpl.java:101)
>  at
> org.aspectj.weaver.internal.tools.PointcutExpressionImpl.matchesMethodExecution(PointcutExpressionImpl.java:92)
>  at
> org.springframework.aop.aspectj.AspectJExpressionPointcut.getShadowMatch(AspectJExpressionPointcut.java:370)
>  at
> org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:247)
>  at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:214)
>
> Looks like the customer is running AspectJ 1.5, so the fix for this NPE is
> not installed.  Customer is
> running in a Java 1.5 environment.
>
> Our monitoring product no longer uses AspectJ.
>
> Have a couple of questions relating to this exception:
>
> 1)  What are the exact circumstances that cause this problem to occur?  I am
> trying to determine why the
> application has no problem when running without the monitoring product, but
> experiences the failure
> when the monitor is installed.  There must be some subtle change to the
> environment that is exposing
> this problem, but I can't put my finger on what it is.
>
> 2) One possible solution is to have the customer upgrade to AspectJ 1.6,
> where it looks like this problem
> is fixed.  However, I am concerned about compatibility with Spring (not sure
> what release the customer is running).  Are there any known issues with
> attempting this upgrade?
>
> Thanks
> --
> View this message in context: http://aspectj.2085585.n4.nabble.com/AspectJ-NPE-in-Java15AnnotationFinder-tp2257835p2257835.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


Back to the top