[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] AJDT weaves fine, but aspect-maven-plugin gets adviceDidNotMatch
|
> Note that all of the other aspects are working fine and are siblings of the
> TranslateThrows in the same package. And the whole thing works and weaves
> and translates great in AJDT. I'm a little lost here are where to look next
> for diagnostic information. I have tried splitting the .aj files -- to put
> the soften in one and the after throwing advice in another but that made no
> difference. Only other thing I can think of is that eclipse is using a
> newer AspectJ version (1.6.11?) instead of 1.6.10 which is what the plugin
> seems to be using. Anyone know how to force the plugin to use another
> version? I see 1.6.11 in the maven repo.
It is certainly worth a try with a more recent AspectJ - don't you
just have to set the right dependency level for the compiler version
in the plugin? (a bit like this:)
aspectj.version=1.6.11
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.0</version>
<dependencies>
<!-- NB: You must use Maven 2.0.9 or above or
these are ignored (see MNG-2972) -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<outxml>true</outxml>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
If that doesn't help, please raise a bugzilla and we'll sort it out.
Typically these kinds of thing can be due to compile ordering - and
you just happen to be getting an unfortunate ordering in your maven
builds but a working ordering under AJDT.
cheers
Andy
On 18 August 2011 22:54, Steve Ash <stevemash@xxxxxxxxx> wrote:
> Hello,
>
> I created an aspect to do some exception translation based on the presence
> of an annotation:
>
> public aspect TranslateThrowsAspect {
>
> pointcut AnyAnnotatedMethod() : execution(@TranslateThrows * *.*(..));
> pointcut AnyPublicMethodInAnAnnotatedClass() : execution(public *
> (@TranslateThrows *).*(..));
> pointcut AnyExceptionTranslatorMethod() : execution(*
> ExceptionTranslator.*(..));
>
> pointcut AnyEligibleMethod() :
> ( AnyAnnotatedMethod() && !AnyExceptionTranslatorMethod() ) ||
> ( AnyPublicMethodInAnAnnotatedClass() &&
> !AnyExceptionTranslatorMethod() );
>
> pointcut AnyEligibleMethodCapturingTarget(ExceptionTranslator obj) :
> AnyEligibleMethod()
> && target(obj);
>
> after(ExceptionTranslator obj) throwing (Exception e) :
> AnyEligibleMethodCapturingTarget(obj) {
>
> throw obj.translateException(e);
> }
>
> declare soft: Exception : AnyEligibleMethod();
> }
>
> So if you have @TranslateThrows on a class, then all public methods that
> throw are sent through the exception translator and the checked exceptions
> are softened. When I run my tests with ADJT everything works wonderfully.
> I am using ADJT with M2E-AJDT so its all integrated.
>
> When I run in Maven the softening happens, but the after throwing advice is
> not woven. I see this in the logs:
>
> [INFO] Softening exceptions in type
> 'com.argodata.core.aspect.TranslateThrowsAspectTest$ClassWithNoTranslator'
> (TranslateThrowsAspectTest.java:52) as defined by aspect
> 'com.argodata.core.aspect.TranslateThrowsAspect'
> (TranslateThrowsAspect.class:86(from TranslateThrowsAspect.aj))
> [DEBUG] woven class
> com.argodata.core.aspect.TranslateThrowsAspectTest$ClassWithNoTranslator
> (from
> /home/ashsteph/workspace/java-core-project_trunk/argo-commons/src/test/java/com/argodata/core/aspect/TranslateThrowsAspectTest.java)
> [DEBUG] woven class com.argodata.core.aspect.TranslateThrowsAspectTest (from
> /home/ashsteph/workspace/java-core-project_trunk/argo-commons/src/test/java/com/argodata/core/aspect/TranslateThrowsAspectTest.java)
> [INFO] Softening exceptions in type
> 'com.argodata.core.aspect.TranslateThrowsAspectTest$ClassWithTranslator'
> (TranslateThrowsAspectTest.java:37) as defined by aspect
> 'com.argodata.core.aspect.TranslateThrowsAspect'
> (TranslateThrowsAspect.class:86(from TranslateThrowsAspect.aj))
>
> So I can see the softening happen (note that the soften advice is declared
> in the same .aj file (see above). However, I see no corresponding "Join
> Pointy 'method-execution..." messages for the advice as I do for other
> aspects. Then (confirming again the observations) I get this at the end of
> the test-compile:
>
> [WARNING] advice defined in com.argodata.core.aspect.TranslateThrowsAspect
> has not been applied [Xlint:adviceDidNotMatch]
>
> Note that all of the other aspects are working fine and are siblings of the
> TranslateThrows in the same package. And the whole thing works and weaves
> and translates great in AJDT. I'm a little lost here are where to look next
> for diagnostic information. I have tried splitting the .aj files -- to put
> the soften in one and the after throwing advice in another but that made no
> difference. Only other thing I can think of is that eclipse is using a
> newer AspectJ version (1.6.11?) instead of 1.6.10 which is what the plugin
> seems to be using. Anyone know how to force the plugin to use another
> version? I see 1.6.11 in the maven repo.
>
> Thanks,
>
> Steve
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>