Results 1 to 4 of 4

Thread: No matching factory method found: factory method 'aspectOf'

  1. #1

    Default No matching factory method found: factory method 'aspectOf'

    Hi!

    this is my first try of using tc-server and I encountered a "little" problem in the AOP area. We use compile time weaving to introduce aspects which works fine when building with maven and deploying the WAR to a "normal" tomcat. When the same WAR is dropped to the webapp folder of tc-server I get "No matching factory method found: factory method 'aspectOf'". Seems that the LTW conflicts with CTW classes. We can't use the proxy approach because this omits all aspects on methods in case a method calls a second method on the same instance.

    Can anyone can give me a hint how to solve this conflict or in which direction to dig?

    Thanks in advance

    Jens

  2. #2
    Join Date
    Jun 2006
    Location
    SF Bay Area, California
    Posts
    524

    Default

    Most likely your problem relates to reweaving. Try the following:
    1. Include your CTWed aspects in the war (you are probably already doing this, but just to make sure).
    2. Include an aop.xml listing the CTWed aspect (you can do it easily by passing -outxml to the AspectJ compiler). Make sure that the aop.xml is under META-INF directory in a classpath component.

    -Ramnivas
    Ramnivas Laddad (Follow me on Twitter)
    AspectJ in Action: Enterprise AOP with Spring Applications (2nd edition). Now available!

  3. #3
    Join Date
    May 2009
    Location
    Vancouver
    Posts
    274

    Default

    Ramnivas' makes some great suggestions there, but (as the AspectJ developer) I'd like to know a couple more details - as I think you should have seen an error earlier than "No matching factory method found: factory method 'aspectOf'" which should have been more helpful.

    Did you get no exceptions earlier in your log relating to reweaving?
    Are your compile time aspects annotation style (pure java but annotated with @Aspect, @Pointcut) or code style?

    thanks,
    Andy
    ---
    Andy Clement
    AspectJ Development

  4. #4

    Default solved

    Hi Ramnivas, hi Andy

    many thanks to both of you for your quick reply.
    I first checked Ramnivas hints and this worked right out of the box. All I did was to modify my MVN pom:

    <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>aspectj-maven-plugin</artifactId>
    <version>1.2</version>
    <configuration>
    <verbose>true</verbose>
    <privatescope>false</privatescope>
    <showweaveinfo>true</showweaveinfo>
    <source>1.5</source>
    <target>1.5</target>
    <compliancelevel>1.5</compliancelevel>
    <encoding>UTF-8</encoding>
    <outxmlfile>META-INF/aop.xml</outxmlfile>
    </configuration>
    ....

    so the interesting part is <outxmlfile>.
    I rebuild the WAR and dropped it to tc-server and the error magically disappeard including correctly calling the aspect code.

    I only used @Aspect and @AfterReturning annotations in my class no exception occured earlier in any of the logs (beside I might be blind :-)

    Again thanks to both of you.

    Jens

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •