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

  • Web Bundle and AspectJ

    I am developing a DM Server (2.0.0.M4) based application (Spring 3.0.x).


    My web bundle is using com.springsource.server.web.dm.ServerOsgiBundleXml WebApplicationContext as contextClass

    I am enabling loadTimeWeaving by specifying this

    Code:
    <context:load-time-weaver aspectj-weaving="on"/>
    I am able to get AOP (LoadTimeWeaving AspectJ) to work in pure OSGI Bundles. However in Web bundles I am getting the following error.

    I tried starting DM Server with -javaagent:E:\spring-agent.jar and
    -javaagent:E:\org.springframework.instrument-3.0.0.RC1.jar

    Code:
    Connection(4)-127.0.0.1  Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.weaving.AspectJWeavingEnabler#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loadTimeWeaver': Initialization of bean failed; nested exception is java.lang.IllegalStateException: ClassLoader [org.springframework.osgi.util.BundleDelegatingClassLoader] does NOT provide an 'addTransformer(ClassFileTransformer)' method. Specify a custom LoadTimeWeaver or start your Java virtual machine with Spring's agent: -javaagent:spring-agent.jar

  • #2
    Few more observations on DM Server and AOP

    When are setting ServerOsgiBundleXmlWebApplicationContext as contextClass, it seems dm server is not able to do loadTimeWeaving

    For pure OSGI bundles where AspectJ LoadTimeWeaving works, com.springsource.kernel.osgi.framework.equinox.Ker nelBundleClassLoader is the classloader registered.

    For Web Bundles it fails with org.springframework.osgi.util.BundleDelegatingClas sLoader not being able to transform message

    What is the LoadTimeWeaver class in Spring DM Server ?

    Comment


    • #3
      dm Server should automatically configure the correct LoadTimeWeaver in your application context: com.springsource.kernel.dmfragment.internal.Kernel LoadTimeWeaver but it would appear that's not happening here.

      Could you please open a JIRA, attaching your failing application so that we can investigate?

      Thanks,
      Andy

      Comment


      • #4
        Working with hack

        I tried to set the weaving class explicitly to "com.springsource.kernel.dmfragment.internal.Kerne lLoadTimeWeaver"
        but got classnotfound exception (obviously internal)

        I copied KernelLoadTimeWeaver code and created a local class in my package and then set the weaving class to this local class. AspectJ started working.

        So I will create a JIRA defect with sample project to reproduce the error and post here.

        Comment

        Working...
        X