I've got a Spring-MVC 3.2.4 mavenized project, where I've run into the need
to weave an Aspect into a Spring-MVC class.  I'm able to run the aspect and
the webapp through Eclipse without any problems (Tomcat), but when I try to
package the war from the command line, AspectJ throws a whole bunch of
weaving errors:

    mvn compile
    ...
    ...
    [ERROR] can't determine superclass of missing type
com.lowagie.text.Document
    when weaving type
org.springframework.web.servlet.view.document.AbstractPdfView
    when weaving classes
    when weaving
    when batch building BuildConfig[null] #Files=75 AopXmls=#0
     [Xlint:cantFindType]
    [ERROR] can't determine superclass of missing type
com.lowagie.text.Document
    when weaving type
org.springframework.web.servlet.view.document.AbstractPdfView
    when weaving classes
    when weaving
    when batch building BuildConfig[null] #Files=75 AopXmls=#0
     [Xlint:cantFindType]
    ...
    ...
    ...

I have no com.lowagie.text.* dependencies listed in my pom, as I am not
using and PDF stuff.  What I don't understand is why AspectJ can properly
weave the class when running through Eclipse, but not when I try to compile
it from the command line.


pom.xml (relevant snippets - using aspectJ 1.7.3):

<dependency>
<groupId>org.aspectj</groupId>
 <artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
</dependency>
 <dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
 <version>${aspectj.version}</version>
</dependency>

    ....
    ....

<plugin>
<groupId>org.codehaus.mojo</groupId>
 <artifactId>aspectj-maven-plugin</artifactId>
<version>1.2</version>
<!-- NB: do not use 1.3 or 1.3.x due to MASPECTJ-90 and do not use 1.4
 due to declare parents issue -->
<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>
 <weaveDependencies>
<weaveDependency>
<groupId>org.springframework</groupId>
 <artifactId>spring-webmvc</artifactId>
</weaveDependency>
</weaveDependencies>
 <source>${java.version}</source>
<target>${java.version}</target>
</configuration>
 </plugin>



The Aspect declaraion:

    @Aspect
    public class OptionsPatch {
    @Pointcut("call( *
org.springframework..SpringWildcardServletTilesApplicationContext.getResources(..))
&& if()")
    public static boolean getResources(JoinPoint.EnclosingStaticPart esp) {
    if( /* some condition here */ )
    return true;
    else
    return false;
    }


    @Around("getResources(enc)")
    public Object unboxIOException(ProceedingJoinPoint pjp,
JoinPoint.EnclosingStaticPart enc) throws Throwable {
    try {
    return pjp.proceed();
    } catch (IllegalArgumentException e) {
    throw e;
    }
    }
    }



Do I have to write the pointcut in a more precise manner to avoid this
problem?  Why does it work within the editor but not from the cmd line?


Thanks,

Eric
_______________________________________________
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to