Announcement Announcement Module
Collapse
No announcement yet.
weaving between bundles using load-time-weaver Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • weaving between bundles using load-time-weaver

    Hi!
    In this moment i am facing one problem and really dont know what i am doing wrong. I am coding logging for my webservice using Spring framework and AOP in @AspectJ style. I got two bundles - background and frontend. In background bundle I have LogAspect, which look like this:

    Code:
    @Aspect
    public class LogAspect {
        @Pointcut("@annotation(logMethod)")
        public void logMethodAnnotated(LogMethod logMethod){}
    
        @Before("logMethodAnnotated(logMethod)")
        public void beforeLogMethodAnnotated(JoinPoint jp){
            //actions
        }
    
        @After("logMethodAnnotated(logMethod)")
        public void afterLogMethodAnnotated(JoinPoint jp){
            //actions   
        }
    }
    and META-INF/spring/background-osgi.xml:

    Code:
    <context:annotation-config />
    <context:component-scan base-package="simon.background"/>
    
    <context:load-time-weaver />
    and also META-INF/aop.xml:

    Code:
    <!DOCTYPE aspectj PUBLIC
            "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">
    <aspectj>
    
        <weaver>
    
            <!-- only weave classes in our application-specific packages -->
            <include within="simon.background.*"/>
            <include within="simon.frontend.controller.*"/>
    
        </weaver>
    
        <aspects>
    
            <!-- weave in just this aspect -->        
            <aspect name="simon.background.log.LogAspect"/>
    
        </aspects>
    
      </aspectj>
    In frontend bundle I've just put into aplicationContext.xml
    Code:
    <context:load-time-weaver aspectj-weaving="on" />
    . But the code is acting very strange. I found out, that there is some problem, when I put into my advice methods JoinPoint as argument. (I mean, when I got advice methods without arguments, so there were no JoinPoin in method header, everything has been working fine and advices has been running before and after @LogMethod (my annotation, which I use to say, that i want to log this method) annotated methods). But now it is working like this: - when I start server and so that the bundles are deployed for the first time, then the advices are run just for methods, they are @LogMethod annotated and belongs to background bundle, but not for annotated methods in frontend.controller. - and in addition, when I have done some changes in one of my controllers, saved it and deployed just frontend bundle, then when I run @LogMethod annotated method, I got this error:

    org.springframework.web.util.NestedServletExceptio n: Handler processing failed; nested exception is java.lang.LinkageError: loader constraint violation: when resolving method "simon.background.log.LogAspect.afterLogMethodAnno tated(Lorg/aspectj/lang/JoinPointV" the class loader (instance of com/springsource/kernel/userregion/internal/equinox/KernelBundleClassLoader) of the current class, simon/frontend/controller/HuhController, and the class loader (instance of com/springsource/kernel/userregion/internal/equinox/KernelBundleClassLoader) for resolved class, simon/background/log/LogAspect, have different Class objects for the type /aspectj/lang/JoinPointV used in the signature

    Any ideas what is going on and how can i fix it, so my program will be able to run advices correctly?

    One additional note, it could maybe help: When I run this in Debug mode with advices without JoinPoint argument, I realized, that both advices were running twice for one method.
Working...
X