You have 2 problems in your code
- Your pointcut doesn't match the actual package
- Your advice method only has a single argument whereas 2 are expected.
For the first fix the package in the pointcut expression. com.company.model.controller.UserValidation
should be com.company.controller.UserValidation
.
<aop:config>
<aop:aspect ref="activityLogging">
<aop:pointcut id="validateUser" expression="execution(* com.company.controller.UserValidation.validateUser(java.lang.String,java.lang.String)) and args(username, enteredPassword)"/>
<aop:before pointcut-ref="validateUser" method="logLoginAttempt" arg-names="username"></aop:before>
</aop:aspect>
</aop:config>
In this aspect you have specified args(username, enteredPassword)
which requires that your advice has 2 parameters.
Add those also to your config and your advice.
<aop:before pointcut-ref="validateUser" method="logLoginAttempt" arg-names="username,enteredPassword">
public void logLoginAttempt(String username, String enteredPassword){
activityLogger.info("Login attempt by: " + username);
}
Or remove it from the args clause args(username,..)
.