My current project EAR file (JAR and WAR) is deployed and running in production for many yrs. The EJB 2.0 was part of JAR file. I would like to do some operation before invoking the particular method in a EJB with out touching the EAR file. So wrote simple class which implements MethodBeforeAdvice interface (Spring AOP) and generated runable jar file using eclipse which has set it in the application server classpath. So that new java file will pickup as per the applicationContext configuration and perform the operation as I expected. The new jar file includes applicationContext.xml file and spring AOP depends JAR files like aop, bean, core and aopalliance. In the applicationContext XML file, mapped org.springframework.aop.framework.ProxyFactoryBean with target as EJB Bean class and InterceptorNames as new class name.
I set the jar file in the server classpath and restarted server in unix box but handshake between new jar file and ear file is not happening when I invoke the EJB. The new jar file should invoke before I call particular method in EJB (After look up EJB). Any idea or suggestions?
AOP can be applied to classes at 2 different times: compile-time and run-time. Compile-time AOP is basically annotations that add features to the generated class code. Run-time requires a re-weaving of the original compiled code to add the features as part of the overall class-loading/instantiation process.
I'm not sure precisely what mechanisms are going to be needed here - plus when Eclipse runs the application server, it can sometimes do rude and unpleasant things to the server's configuration.
In the case of Tomcat using JPA, I have to include 2 Spring libraries into the Tomcat server's lib directory, one of which is the spring-tomcat-weaver.jar. Your webapp server, whatever it may be, probably needs something similar.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.