Vita Rara: A Life Uncommon

Workaround the AOP and Groovy classloader

Dear Mark

I have same similar problem like you in my current company project. I have tried a workaround method which "SEEM" to work in my case. But I am not sure that it works in other case. I have created 2 application xml files in my application. The first application xml file contains all the beans and Groovy script definition. The second application xml file contains only the pointcut definition like:

<aop:config>
 <aop:pointcut id="PersonServiceOperation" expression="execution(* org.test.PersonService.*(..))"/>
 <aop:advisor advice-ref="txAdvice" pointcut-ref="PersonServiceOperation"/>
</aop:config>

In my java program, I need to create 2 ApplicationContext like:

ApplicationContext context1 = new ClassPathXmlApplicationContext(
  new String[] {"applicaionContext1.xml"});
ApplicationContext context2 = new ClassPathXmlApplicationContext(
  new String[] {"applicaionContext2.xml"}, context1);

It seems that if I pass the context1 to create context2, the AspectJ classloader and GroovyClassloader are not sibiling any more and AspectJ classloader can see the Groovy Class implementation interface. I have already posted my workaround to the spring forum. But I am not sure that my workaround will have any problem in other cases. If you find any problems with my workaround, please let me know so that I can avoid the problem in my project. My email is ctam@xeniumhk.com Thanks a lot for your help.

Thanks
chris tam
xenium

Reply

Please solve the math problem above and type in the result. e.g. for 1+1, type 2
  • Allowed HTML tags: <a> <img> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre> <h1> <h2> <h3>
  • Lines and paragraphs break automatically.
More information about formatting options