Wicket
  1. Wicket
  2. WICKET-5264

CDI Injection no longer working on anonymous classes

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 6.9.0
    • Fix Version/s: 6.9.1
    • Component/s: wicket-cdi
    • Labels:
      None

      Description

      The changes made for WICKET-5226 (no longer injecting anonymous inner classes) breaks our applications badly, and I suspect we are not the only one. The following pattern is quite common:

      add(new Link<Void>("rest") {
      @Inject
      private AccountRestResourceClient accountClient;

      @Override
      public void onClick()

      {....}

      }

      In Wicket 6.9.0, this no longer works: accountClient will not get injected because the Link is an anonymous inner class. To make things worse, even in concrete classes, you can't rely on injection to work, because someone could subclass your class as an anonymous inner class and injection will again not work.

      This change was made because Weld 2.0 throws an exception when trying to create an InjectionTarget for anonymous classes. This will be reduced to a log-warning in 2.0.2: https://issues.jboss.org/browse/WELD-1441

        Issue Links

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              Emond Papegaaij
              Reporter:
              Emond Papegaaij
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development