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,


    I'm trying to setup a spring managed @AspectJ style aspect. Just to be clear I'm using AspectJ, not SpringAOP, with the Tomcat LTW.

    Upon application statup I get the following error, when Spring tres to initialize my aspect.

    Code:
    No matching factory method found: factory method 'aspectOf'
    This would imply that the aspectOf method needs to be implement on my aspect. Yet, I haven't seen any mention of this requirment in the docs. If I were using CTW the compile time weaver would have added this method for me. Does the LTW not provide this method?

    I've included my Aspect, aop.xml, and portions of my application context.xml below. Anythoughts would be helpful

    My Aspect:
    Code:
    @Aspect
    public class SetUserCredentialsAspect extends JdbcDaoSupport{
    
        @Pointcut("initialization(webservices.service.admin.*.new(..))")
        private void adminServices(){}
    
        //@Pointcut("")
        //private void userValidatorInterceptor(){}
    
        @Before("adminServices")
        private void  setAdminServices()
        {
            logger.warn("^^^^^^^^^^^^^^^^^^^HERE^^^^^^^^^^^^^^^^^^^^^");
        }
        public static SetUserCredentialsAspect aspectOf(){
            return Aspects.aspectOf(SetUserCredentialsAspect.class);
        }
    }
    My Aop.xml
    Code:
    <aspectj>
        <weaver options="-showWeaveInfo -verbose">
            <include within="webservices"/>
         </weaver>
        <aspects>
            <aspect name="org.springframework.transaction.aspectj.AnnotationTransactionAspect" />
            <aspect name="gov.gov.ic.dia.wiseism.webservices.aspects.SetUserCredentialsAspect" />
        </aspects>
    </aspectj
    ApplicationContext.xml
    Code:
       <!-- Turn on the LTW -->
        <context:load-time-weaver aspectj-weaving="on" />
    
        <tx:annotation-driven transaction-manager="transactionManager" order="1000" mode="aspectj" />
    
        <!-- Turn on Aspect J -->
        <!--<aop:aspectj-autoproxy/>-->
    
    
        <bean class="org.springframework.transaction.aspectj.AnnotationTransactionAspect" factory-method="aspectOf" dependency-check="none">
            <property name="transactionManager" ref="transactionManager"/>
        </bean>
    
        <bean id="setUserCredentialsAspect" class="webservices.aspects.SetUserCredentialsAspect" factory-method="aspectOf"  dependency-check="none">
            <property name="jdbcTemplate" ref="jdbcTemplate"/>
        </bean>

  • #2
    The setup looks right to me (except you don't need AnnotationTransactionAspect bean, since tx:annoation-driven will cover that). I suspect that load-time weaver setup isn't right. Do you see any output from the weaver (since you have specified -showWeaveInfo and -verbose)?

    -Ramnivas

    Comment

    Working...
    X