0

I am using spring security and aspjectj with compile time weaving. I am trying to log successful user login. My pointcut looks as follows. but it is not getting

@Pointcut("execution(* com.myapp.dao.UserDao.loadUserByUsername(..))")
private void pointcutUserLoginLogging() {}


@AfterReturning(pointcut="pointcutUserLoginLogging()")
public void doUserLogging(JoinPoint joinPoint){

}

The method I am trying to inspect has the following signature

public class UserDao extends AbstractDao<User> implements GenericDao<User>, UserDetailsService {     
@Transient
public UserDetails loadUserByUsername(String username)
throws UsernameNotFoundException, DataAccessException {
    return loadByUsername(username);
}
}
user373201
  • 10,945
  • 34
  • 112
  • 168
  • What you have shown looks okay. So I suspect your build configuration to have problems. How are you building? Show a bit of that code. – ramnivas Jan 30 '11 at 17:20
  • I am using maven to compile. I have other aspects in my application and they all work fine. During the build process, I see a lot of logs about which classes are getting weaved, but the UserDao does not show up. I put a break point while working with the code and same thing, it does not go into the method – user373201 Jan 30 '11 at 18:30
  • Is the method (loadUserByUsername) in the UserDao class? It may help if you show the skeleton of the UserDao class and explain a bit of the inheritance hierarchy. – ramnivas Jan 31 '11 at 03:31
  • I have added the class decl to above code..AbstractDao is an abstract class and GenericDao is an interface – user373201 Jan 31 '11 at 15:42
  • Important thing I forgot to mention....my code to be inspected is in a different jar file. When i compile, the main project, I guess it does not weave the jars. – user373201 Jan 31 '11 at 16:22
  • I did not state the requirements correctly. I got my answer from this post http://stackoverflow.com/questions/4853292/spring-aspectj-compile-time-weaving-external-jar. Ramnivas, thank you for the help. can you provide your comment as answer so that I can accept it – user373201 Jan 31 '11 at 16:55

1 Answers1

0

This kind of issue almost always points to build setup problem. Just make sure that the jars that you want to be woven in is in "inpath" and aspects are in "aspectspath". Maven, Ant, Eclipse/AJDT all provide a way to include jars in appropriate paths.

ramnivas
  • 1,264
  • 10
  • 13