I am weaving the spring-mvc jar, as the code I am trying to wrap is from
the Spring-MVC jar. I believe the equivalent of the maven configuration
parameters
<weaveDependencies>
<weaveDependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</weaveDependency>
</weaveDependencies>
is: ajc -inpath <path-to spring-mvc.jar>.
So, I am expecting it to be weaving the Spring libraries. I just do not
understand why it is failing on those classes which do not call
*.getResources().
I do not seem to be able to properly figure out how to code the within()
clause appropriately. Can you please advise? I am trying to create a
pointcut
around
org.springframework..SpringWildcardServletTilesApplicationContext.getResources(..)
when called from within org.apache.tiles.extras.renderer.OptionsRenderer
class.
At the moment, my ugly if() condition checks the stacktrace to validate
that OptionsRenderer is the calling method, as I was unable to figure out
the correct syntax for getting the within() clause to work appropriately.
I thought it would be:
@Pointcut("within(org.apache.tiles.extras.renderer.OptionsRenderer)
&& call( *
org.springframework..SpringWildcardServletTilesApplicationContext.getResources(..))")
but that does not seem to be accurate.
Any advice would be appreciated.
Thanks,
Eric
On Tue, Nov 19, 2013 at 8:40 PM, Andy Clement <[email protected]>wrote:
> Seems a little odd it is saying it is weaving into Spring classes:
>
> " when weaving type org.springframework.web.servlet.view.document.
> AbstractPdfView"
>
> Are you somehow passing in more than the application? I don't speak maven
> so can't comment directly on the pom contents. You could include a
> within() clause in your pointcut to limit it to the packages you really
> know contain the calls then it won't be looking at all the calls made
> everywhere.
>
> cheers,
> Andy
>
>
>
> On 14 November 2013 19:58, Eric B <[email protected]> wrote:
>
>> 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
>> [email protected]
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>
>>
>
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users