-
Nov 2nd, 2009, 04:08 AM
#1
NoSuchMethodError:Aspect.aspectOf()
Hi,
I am trying to put LTW into an existing application.
I have created a poc on how can I weave the advice around an object which is not managed by the Spring container, my pos works very well, and I am able to weave the advice around the target object.
But when I am trying to apply the same concept into the real application(its a web app), it seems like aspectJ recognised my advice and target object to be adviced, but while trying to execute the advice method, it throws the following exception:
15:17:25: ERROR: BaseCtrl.execute: Caught Throwable: foo/ProfilingAspect.aspectOf()Lfoo/ProfilingAspect;
java.lang.NoSuchMethodError: foo/ProfilingAspect.aspectOf()Lfoo/ProfilingAspect;
my aspect ie ProfilingAspect does not implement any aspectOf() method, I am not sure how can I implement it,also in my pos application,I did not implement any aspectOf() method in my aspect, and it works fine.
Could somebody please help me to understand whats going wrong here?
Following are my classes and config:
Aspect class:-
package foo;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.util.StopWatch;
@Aspect
public class ProfilingAspect {
@Around("methodsToBeProfiled()")
public Object profile(ProceedingJoinPoint pjp) throws Throwable {
StopWatch sw = new StopWatch(getClass().getSimpleName());
System.out.println("my advice called........");
try {
sw.start(pjp.getSignature().getName());
return pjp.proceed();
} finally {
sw.stop();
System.out.println(sw.prettyPrint());
}
}
@Pointcut("execution(public * com.mypackage..*.*(..))")
public void methodsToBeProfiled(){}
}
aop.xml:-
<!DOCTYPE aspectj PUBLIC
"-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">
<aspectj>
<weaver options="-verbose -showWeaveInfo -debug">
<!-- only weave classes in our application-specific packages -->
<include within="com.mypackage.*"/>
</weaver>
<aspects>
<!-- weave in just this aspect -->
<aspect name="foo.ProfilingAspect"/>
</aspects>
</aspectj>
beans definition:-
<bean id="entitlementCalculationService"
class="foo.StubEntitlementCalculationService"/>
<bean id="aBean" class="foo.ProfilingAspect"/>
<!-- this switches on the load-time weaving -->
<context:load-time-weaver weaver-class="org.springframework.instrument.classloading .InstrumentationLoadTimeWeaver"/>
following are the versions I am using:
Spring 2.5
aspectjrt-1.5.4.jar
aspectjweaver-1.5.3.jar
spring-agent-2.5.6.jar
Thanks,
Nitin.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules