Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-458

JAX-RS property injection not working for non-CDI components when CdiInjectorFactory is used

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical Critical
    • 2.1-beta-1
    • 2.0.GA
    • None
    • None
    • Release Notes

      The default RESTEasy process for creating a component instance is the following:
      1.) Obtain an instance by calling ConstructorInjector.construct(class)
      2.) Perform JAX-RS injection by calling PropertyInjector.inject(instance)

      However, in CDI environment the PropertyInjector.inject() call would fail (Since the ConstructorInjector returns a proxied instance) Therefore, in a CDI environment, JAX-RS property injection is done during bean instantiation.

      As a result, PropertyInjector.inject() would be called twice:
      1.) - by the resteasy-cdi extension during bean instantiation
      2.) - by RESTEasy (this attempt would fail with exception since Weld proxies throw IllegalArgumentException on field injection attempt)

      In order to avoid double property injection, the CdiInjectorFactory return a NoopPropertyInjector. This works as expected for CDI-enabled JAX-RS components but causes JAX-RS property injection not to work for non-CDI-enabled JAX-RS components in a CDI-enabled deployment. (i.e. a CDI-enabled war archive that bundles a non-CDI archive with a set of providers - i.e. JSON support)

              rhn-engineering-jharting Jozef Hartinger
              rhn-engineering-jharting Jozef Hartinger
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: