Announcement Announcement Module
Collapse
No announcement yet.
No matching factory method found: factory method 'aspectOf' Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


    • #3
      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

      Comment


      • #4
        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

        Comment

        Working...
        X