i really hope someone can help me, i am trying to create some very simple AOP Operations in my web-application. Unfortunately it is not triggered at all. Here my configs: web.xml (to load application.xml)
<!-- web.xml -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/application*.xml</param-value>
</context-param>
And the application.xml
<!--application.xml-->
<aop:aspectj-autoproxy proxy-target-class="true" /> <!-- i tried with and without proxy-->
<bean id="config" class="com.whatever.config.Configuration"/> <!-- beans are not definend in application.xml, but in a separate class-->
The config class
@Configuration
@PropertySource({ "classpath:/ui.properties" })
@Import({ somclass.class, ScanBean.class})
public class Configuration {
}
The scanbean class
@Configuration
@ComponentScan(basePackages = { "com.ui.common", "com.ui.aspects" })
public class ScanBean {
@Bean
public DefaultEntityServiceAspect defaultEntityServiceAspect() {
return new DefaultEntityServiceAspect();
}
}
Beans are there and everything starts without any error. The aspect beans... The annotation
@Retention(RetentionPolicy.RUNTIME)
public @interface DefaultEntity {}
// the aspect itself
@Aspect
public class DefaultEntityServiceAspect {
private final Logger logger = Logger.getLogger(DefaultEntityServiceAspect.class);
@Around("@annotation(com.ui.aspects.DefaultEntity)")
public void setDefaultEntityFields(ProceedingJoinPoint joinPoint) throws Throwable {
logger.warn("doing something 2 huhu");
joinPoint.proceed();
}
}
And finally the bean itself
@Service
@Scope("session")
public class AdminBean implements Serializable {
// some code...
@DefaultEntity
public void wtfIsWrongWithYou() {
logger.debug("am i working?");
}
}
If i write a simple JUNIT Test, it is working like expected. As soon as i deployed it to the server (tomcat). Nothing works anymore. I found a 1000 tips, but non of them was working. I think i read everything here on stackoverflow :) but a solution was not found. I would really appreciate every tip.
Cheers!
Edit:
I created a small project on github. I still did not get it run .. if someone has a hint, please let me know! Thank you!