Skip to main content

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

Thanks for the quick response. You da man!!

 

Initially, I added the inclusion pattern to just the aspect tag

<aspect>

            <!-- other stuff -- >

            <include within="foo.bar.*"/> <!-- aspect class XYZ is in the foo.bar package à

</aspect>.

 

 As per your suggestion, I added the same to the weaver tag as well :meaning: the Aspect has to be weaved with the aspectOf method. It works !!!

<weaver>

<!-- other stuff -- >

            <include within="foo.bar.*"/>

</weaver>

 

Thanks again,

Sunder

 

 

 

From: Andy Clement <andrew.clement@xxxxxxxxx>

Date: Thu, 11 Mar 2010 21:17:51 -0800

Delivered-to: aspectj-users@xxxxxxxxxxx

 

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

 


From: Tatta, Sunder
Sent: Thursday, March 11, 2010 8:22 PM
To: 'aspectj-users@xxxxxxxxxxx'
Subject: Hack to get around NoSuchMethodError aspectOf exception using LTW - Aspectj 1.6.8

 

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


Back to the top