dm Server
  1. dm Server
  2. DMS-2490

@Configurable doesn't work with ServerOsgiBundleXmlWebApplicationContext

    Details

    • Type: Defect Defect
    • Status: Done Done
    • Priority: Minor Minor
    • Resolution: Complete
    • Affects Version/s: 2.0.0.RC1, 2.0.0.RELEASE, 2.0.1.RELEASE
    • Fix Version/s: Sprint 27, 2.0.2.RELEASE
    • Component/s: None
    • Labels:
      None
    • Environment:
      • Windows XP
      • STS 2.3.2.RELEASE
      • Springsource DM Server 2.0 (1.0)
      • Springframework 3.0 (2.5)

      Description

      I have a problem with using @Configurable annotated beans in a web application (war bundle).
      Everything works fine without contextClass parameter in web.xml

      <context-param>
      	<param-name>contextClass</param-name>
      	<param-value>com.springsource.server.web.dm.ServerOsgiBundleXmlWebApplicationContext</param-value>
      </context-param>
      

      If contextClass paramter is present in web.xml I'm getting exception:

      start-signalling-6 org.springframework.web.context.ContextLoader
      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

      As far as I know I need to have ServerOsgiBundleXmlWebApplicationContext defined in web.xml while it enables

      <reference ... />

      Please see attached simple application, which is not working either on Springsource DM 2.0 or 1.0.
      After removing ServerOsgiBundleXmlWebApplicationContext @Configurable works as expected.

        Activity

        Hide
        Glyn Normington (c) added a comment -

        Thanks for raising this Igor. I am keen to get to the bottom of it as it seems to be a fairly basic problem.

        Show
        Glyn Normington (c) added a comment - Thanks for raising this Igor. I am keen to get to the bottom of it as it seems to be a fairly basic problem.
        Hide
        Glyn Normington (c) added a comment -

        Some initial preparation work, for the record...

        This situtation should be handled by KernelLoadTimeWeaver:

        kernel/com.springsource.kernel.dmfragment/src/main/java/com/springsource/kernel/dmfragment/internal/KernelLoadTimeWeaver.java

        This is a custom LoadTimeWeaver implementation that understands how to
        go from a BundleDelegatingClassLoader to the ClassLoader for the bundle
        that does provide an addTransformer method.

        We use a BeanFactoryPostProcessor to automatically replace an
        application context's LoadTimeWeaver bean (if it has one) with an
        instance of KernelLoadTimeWeaver:

        kernel/com.springsource.kernel.dmfragment/src/main/java/com/springsource/kernel/dmfragment/internal/LoadTimeWeaverPostProcessor.java

        A plan of attack is to figure out why this
        replacement isn't happening, i.e. either the BeanFactoryPostProcessor
        isn't being driven, or it's failing to switch in the
        KernelLoadTimeWeaver for some reason.

        Note also that LoadTimeWeavingTests should exercise this function and is currently passing. However, this is a kernel test and not at all web-ish, which seems to be the key.

        Show
        Glyn Normington (c) added a comment - Some initial preparation work, for the record... This situtation should be handled by KernelLoadTimeWeaver: kernel/com.springsource.kernel.dmfragment/src/main/java/com/springsource/kernel/dmfragment/internal/KernelLoadTimeWeaver.java This is a custom LoadTimeWeaver implementation that understands how to go from a BundleDelegatingClassLoader to the ClassLoader for the bundle that does provide an addTransformer method. We use a BeanFactoryPostProcessor to automatically replace an application context's LoadTimeWeaver bean (if it has one) with an instance of KernelLoadTimeWeaver: kernel/com.springsource.kernel.dmfragment/src/main/java/com/springsource/kernel/dmfragment/internal/LoadTimeWeaverPostProcessor.java A plan of attack is to figure out why this replacement isn't happening, i.e. either the BeanFactoryPostProcessor isn't being driven, or it's failing to switch in the KernelLoadTimeWeaver for some reason. Note also that LoadTimeWeavingTests should exercise this function and is currently passing. However, this is a kernel test and not at all web-ish, which seems to be the key.
        Hide
        Glyn Normington (c) added a comment -

        This problem was caused because the kernel's bean factory post processors (BFPPs) such as LoadTimeWeaverPostProcesser are only driven for bundles processed by the Spring DM extender. Changing the web layer to drive the kernel's BFPPs for bundles specifying an application context of type com.springsource.server.web.dm.ServerOsgiBundleXmlWebApplicationContext fixed the problem. This fix will be shipped in dm Server 2.0.2 and will be forward ported to Virgo.

        Show
        Glyn Normington (c) added a comment - This problem was caused because the kernel's bean factory post processors (BFPPs) such as LoadTimeWeaverPostProcesser are only driven for bundles processed by the Spring DM extender. Changing the web layer to drive the kernel's BFPPs for bundles specifying an application context of type com.springsource.server.web.dm.ServerOsgiBundleXmlWebApplicationContext fixed the problem. This fix will be shipped in dm Server 2.0.2 and will be forward ported to Virgo.
        Hide
        Glyn Normington (c) added a comment -

        Fix forward ported to Virgo or, more precisely, to the private kernel and web repositories which will be contributed to Virgo.

        Show
        Glyn Normington (c) added a comment - Fix forward ported to Virgo or, more precisely, to the private kernel and web repositories which will be contributed to Virgo.
        Hide
        Glyn Normington (c) added a comment -

        Fixed in 2.0.x line in readiness for 2.0.2. Forward ported to Virgo. Regression test added to Virgo.

        Show
        Glyn Normington (c) added a comment - Fixed in 2.0.x line in readiness for 2.0.2. Forward ported to Virgo. Regression test added to Virgo.

          People

          • Assignee:
            Glyn Normington (c)
            Reporter:
            Igor Banduric
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              First Response Date:

              Time Tracking

              Estimated:
              Original Estimate - 8.5h
              8.5h
              Remaining:
              Remaining Estimate - 0h
              0h
              Logged:
              Time Spent - 5h 35m Time Not Required
              5h 35m