Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-1645

ResourceInjector fails to inject into (Spring) proxies if resource to be in injected is subclassed

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1, 2.0.6, 2.1.1, 2.0.7
    • Fix Version/s: 2.1.1, 2.0.7
    • Component/s: Core
    • Labels:
      None

      Description

      If the target is a proxy ResourceInjector tries to resolve an appropriate setter method for the resource using

      Method targetMethod = getTarget().getClass().getMethod(method.getName(), new Class[]

      {resource.getClass()}

      );
      targetMethod.invoke(getTarget(), resource);

      This fails if the resource has been subclassed because getMethod() (still) does only exact matches (see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4287725).

      This is (for example) the reason why injecting the WebServiceContext into a (Spring) proxy does not work: The real implementation WebServiceContextImpl is always a subclass (see thread http://www.mail-archive.com/cxf-user@incubator.apache.org/msg03050.html)

      As a solutions, the ResourceInjector might implement it's own matching algorithm or e. g. use Spring's MethodInvoker instead which already contains such an algorithm:

      MethodInvoker targetInvoker = new MethodInvoker();
      targetInvoker.setTargetObject(getTarget());
      targetInvoker.setTargetMethod(method.getName());
      targetInvoker.setArguments(new Object[]

      {resource}

      );
      targetInvoker.prepare();
      targetInvoker.invoke();

        Attachments

        1. ResourceInjector.patch
          8 kB
          Andreas Benneke

          Issue Links

            Activity

              People

              • Assignee:
                dkulp Daniel Kulp
                Reporter:
                benneke Andreas Benneke
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: