Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Hack to get around NoSuchMethodError aspectOf exception using LTW - Aspectj 1.6.8

Hello,

There should be no need to add that method yourself.  Are you by any
chance excluding the aspect type in your LTW aop.xml configuration?
That method (aspectOf) is added during weaving.  If your original
annotation style aspect was built with javac rather than ajc, then it
will not have it in when the JVM starts because the weaver hasn't yet
run - thus the type must go to the load time weaver in order to be
finished off.  If the patterns for inclusion/exclusion in the aop.xml
fail to include the aspect it will not be finished off and you will
get that NoSuchMethod problem.

Let me know what your aop.xml says and the fully qualified name of the aspect.

cheers,
Andy

On 11 March 2010 17:21, Tatta, Sunder <statta@xxxxxxxxxxxxxxxxxxxxx> wrote:
> In response to an earlier post à  [aspectj-users] NoSuchMethod aspectOf
> exception using LTW.
>
>
>
> I have an aspect class which kept constantly failing with the above
> NoSuchMethodError. To get around it,
>
> I just added the method it was unable to find. See below
>
> @Aspect
>
> Class XYZ
>
> {
>
>
>
> @Around("execution(* foo.bar(..))")
>
>    public Object applyAround(ProceedingJoinPoint jp)
>
>    throws Throwable
>
> {
>
> // some code
>
>
>
> }
>
> // added this method and things were back to normal
>
> public static XYZ aspectOf()
>
>    {
>
>       return  new XYZ();
>
>    }
>
> // tried this but the method took for ever to return and finally the
> application ran out of memory
>
> /*
>
>  public static XYZ aspectOf()
>
>    {
>
>       return Aspects.aspectOf(XYZ.class);
>
>    }
>
> */
>
>
>
> }
>
>
>
> Not sure if there is a better long term fix (like a setting in aop.xml). I
> don’t want to add this method for every aspect I’m writing nor do I want to
> use “compile time weaving (ajc)” for the aspects. Can anyone provide a
> better solution?
>
> Please Note:
>
> When Mr. Andrew Clement fixed the issue below, he released a Dev version
> (please refer to the comments in the bug report - 1.6.4 Dev) which was
> working perfectly. None of the later versions out there seem to work without
> the hack.
>
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=279298
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>


Back to the top