Announcement Announcement Module
Collapse
No announcement yet.
AspectJ LTW issue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AspectJ LTW issue

    I am trying to get aspectj ltw working in my app.

    My app is structured like below

    Test
    -- TestCommon
    -- TestPersistence
    -- TestWeb

    where Test is the base EAR project.

    I have created a simple logging aspect and placed it in TestCommon. The aop.xml has been placed in TestCommon/Meta-Inf folder.

    The problem is with the class loading policy of the app. By default the war class loader policy is set to module. In this case the LTW doesnt seem to work i.e the app doesnt seem to recognize the aspect and ltw doesnt work.

    But if I change the war class loader policy to Application, then everything works fine.

    What I understand is with module setting , there are 2 class loaders, one for the application and one for the war. In this case the war classes are not recognized. If I move the aop.xml to the web folder , then my other classes in the other projects like TestCommon and TestPersistence are not weaved.

    Is there a solution to this issue without changing the war classloader mode to application?

  • #2
    Some more info.

    My spring application-context has the line
    <context:load-time-weaver aspectj-weaving="on" weaver-class="org.springframework.instrument.classloading .websphere.WebSphereLoadTimeWeaver" />


    The output from aspectj is

    [31/01/13 16:02:48:188 GMT+05:30] 000008a7 SystemErr R [CompoundClassLoader@77b971b] info AspectJ Weaver Version 1.6.9 built on Monday Jul 5, 2010 at 15:28:35 GMT
    [31/01/13 16:02:48:188 GMT+05:30] 000008a7 SystemErr R [CompoundClassLoader@77b971b] info register classloader com.ibm.ws.classloader.CompoundClassLoader@77b971b
    [31/01/13 16:02:48:188 GMT+05:30] 000008a7 SystemErr R [CompoundClassLoader@77b971b] info using configuration /C:/Workspaces/Test_Workspace/TestCommon/bin/META-INF/aop.xml
    [31/01/13 16:02:49:204 GMT+05:30] 000008a7 SystemErr R [CompoundClassLoader@77b971b] info register aspect com.test.aspect.GenericLoggingAspect
    [31/01/13 16:02:49:344 GMT+05:30] 000008a7 SystemErr R [CompoundClassLoader@77b971b] debug not weaving 'org.springframework.instrument.classloading.websp here.WebSphereClassPreDefinePlugin$Dummy'

    [31/01/13 16:03:48:845 GMT+05:30] 000008a7 SystemErr R [CompoundClassLoader@77b9823] info AspectJ Weaver Version 1.6.9 built on Monday Jul 5, 2010 at 15:28:35 GMT
    [31/01/13 16:03:48:845 GMT+05:30] 000008a7 SystemErr R [CompoundClassLoader@77b9823] info register classloader com.ibm.ws.classloader.CompoundClassLoader@77b9823
    [31/01/13 16:03:48:845 GMT+05:30] 000008a7 SystemErr R [CompoundClassLoader@77b9823] info using configuration /C:/Workspaces/Test_Workspace/TestCommon/bin/META-INF/aop.xml
    [31/01/13 16:03:48:861 GMT+05:30] 000008a7 SystemErr R [CompoundClassLoader@77b9823] info register aspect com.test.aspect.GenericLoggingAspect
    [31/01/13 16:03:48:876 GMT+05:30] 000008a7 SystemErr R [CompoundClassLoader@77b9823] debug weaving 'com.test.web.controllers.base.BaseController'
    [31/01/13 16:03:49:486 GMT+05:30] 000008a7 SystemErr R [CompoundClassLoader@77b9823] weaveinfo Join point 'method-execution(java.lang.String com.test.web.controllers.base.BaseController.forwa rd(com.test.web.navigation.Navigator, java.lang.String, java.lang.String))' in Type 'com.test.web.controllers.base.BaseController' (BaseController.java:45) advised by before advice from 'com.test.aspect.GenericLoggingAspect' (GenericLoggingAspect.java)

    If you look at this there are 2 class loaders the first being the app class loader and the second being the war class loader. The war class loader seems to be doing the weaving correctly but the app class loader though it kicks off does not do anything. Does it have anything to do with the fact that spring is doing the LTW and possibly the weaver instance is being overwritten by the second class loader?

    Comment

    Working...
    X