Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-13754

Allow injection for JSF artifacts

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 22.0.0.Alpha1, 22.0.0.Final
    • 20.0.1.Final
    • JSF
    • None
    • Hide

      The issue was discovered testing the mojarra test-suite with wildfly. The test injectArtifacts checks for this feature.

      Deploy the attached test-javaee6web-injectArtifacts.war. The test cannot be directly compiled cos wildfly doesn't inject any com.sun.faces object, so the test suite com.sun.faces.test is also not injected, I modified the test to use another package name (see this line).

      Access the app: http://localhost:8080/test-javaee6web-injectArtifacts/

      Only the phase-listener is injected (all the elements are created by the JSF impl but not properly initialized by the CDI):

      FacesConfigApplicationFactory: null @PostConstruct called
      FacesConfigActionListener: null @PostConstruct called
      FacesConfigNavigationHandler: null @PostConstruct called
      FacesConfigViewHandler: null @PostConstruct called
      FacesConfigStateManager: null @PostConstruct called
      FacesConfigELResolver: null @PostConstruct called
      FacesConfigResourceHandler: null @PostConstruct called
      FacesConfigSystemEventListener: null @PostConstruct called
      FacesConfigPhaseListener: Injected from value specified in web.xml @PostConstruct called
      
      Show
      The issue was discovered testing the mojarra test-suite with wildfly. The test injectArtifacts checks for this feature. Deploy the attached test-javaee6web-injectArtifacts.war . The test cannot be directly compiled cos wildfly doesn't inject any com.sun.faces object, so the test suite com.sun.faces.test is also not injected, I modified the test to use another package name (see this line ). Access the app: http://localhost:8080/test-javaee6web-injectArtifacts/ Only the phase-listener is injected (all the elements are created by the JSF impl but not properly initialized by the CDI): FacesConfigApplicationFactory: null @PostConstruct called FacesConfigActionListener: null @PostConstruct called FacesConfigNavigationHandler: null @PostConstruct called FacesConfigViewHandler: null @PostConstruct called FacesConfigStateManager: null @PostConstruct called FacesConfigELResolver: null @PostConstruct called FacesConfigResourceHandler: null @PostConstruct called FacesConfigSystemEventListener: null @PostConstruct called FacesConfigPhaseListener: Injected from value specified in web.xml @PostConstruct called

      In the JSF 2.3 specification chapter 5.4.1 JSF Managed Classes and Java EE Annotations the following statement is said:

      JSF Implementations that are running as a part of Java EE 5 (or later) must allow managed bean implementations to use the annotations specified in section 14.5 of the Servlet 2.5 Specification to allow the container to inject references to container managed resources into a managed bean instance before it is made accessible to the JSF application. Only beans declared to be in request, session, or application scope are eligible for resource injection.

      In addition to managed beans being injectable in this manner, the following JSF artifacts are also injectable.

      And the following table of JSF classes are listed:

      • javax.el.ELResolver
      • javax.faces.application.ApplicationFactory
      • javax.faces.application.NavigationHandler
      • javax.faces.application.ResourceHandler
      • javax.faces.application.StateManager
      • javax.faces.component.visit.VisitContextFactory
      • javax.faces.context.ExceptionHandlerFactory
      • javax.faces.context.ExternalContextFactory
      • javax.faces.context.FacesContextFactory
      • javax.faces.context.PartialViewContextFactory
      • javax.faces.event.ActionListener
      • javax.faces.event.SystemEventListener
      • javax.faces.lifecycle.ClientWindowFactory
      • javax.faces.lifecycle.LifecycleFactory
      • javax.faces.event.PhaseListener
      • javax.faces.render.RenderKitFactory
      • javax.faces.view.ViewDeclarationLanguageFactory
      • javax.faces.view.facelets.FaceletCacheFactory
      • javax.faces.view.facelets.TagHandlerDelegateFactory

      The JIRA WFLY-6617 added phase listeners for injection but in general this should follow the spec and allow injection in all the commented components. The idea is adding some more elements available for injection as mojarra did (check this issue).

              rhn-support-rmartinc Ricardo Martin Camarero
              rhn-support-rmartinc Ricardo Martin Camarero
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: