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

Allow injection for Validator/Converter/Behavior if managed=true

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 22.0.0.Final
    • 21.0.0.Final
    • JSF
    • None
    • Hide
      • Compile and package the attached inject-converter:
      unzip inject-converter.zip
      cd inject-converter
      mvn clean package
      
      • Deploy the resulting inject-converter.war. The exception is thrown at deploy time and deployment is stopped.
      • The application is just a page that validates an URL input using the injected converter.
      Show
      Compile and package the attached inject-converter : unzip inject-converter.zip cd inject-converter mvn clean package Deploy the resulting inject-converter.war . The exception is thrown at deploy time and deployment is stopped. The application is just a page that validates an URL input using the injected converter.
    • Undefined
    • ---
    • ---

      The JSF spec 2.3 explicitly states in chapter 5.9.1 - JSF Objects Valid for @Inject Injection that:

      It must be possible to use @Inject when specifying the following kinds of JSF managed objects.

      • Validators declared with @javax.faces.validator.FacesValidator(managed=”true”)
      • Converters declared with @javax.faces.convert.FacesConverter(managed=”true”)
      • FacesBehaviors declared with @javax.faces.component.behavior.FacesBehavior(managed=”true”)

      The idea in javaee8 is that now a Converter (for example) can be annotated this way:

      @FacesConverter(value = "urlConverter", managed = true)
      public class URLConverter implements Converter {
      

      And it can be injected in a bean for example:

      @Named(value="urlConverterBean")
      @RequestScoped
      public class UrlConverterBean {
      
          @Inject
          @FacesConverter(value = "urlConverter", managed = true)
          private URLConverter urlConverter;
      

      In the current wildfly this throws the following exception at deploy time:

      ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC000001: Failed to start service jboss.deployment.unit."inject-converter.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."inject-converter.war".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment "inject-converter.war"
      	at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:189)
      	at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1739)
      	at org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1701)
      	at org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1559)
      	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
      	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
      	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
      	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1363)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYJSF0009: Annotation FACES_CONVERTER in class com.sample.jsf.URLConverter com.sample.jsf.UrlConverterBean.injectConverter3 is only allowed on classes
      	at org.jboss.as.jsf.deployment.JSFAnnotationProcessor.deploy(JSFAnnotationProcessor.java:122)
      	at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:182)
      	... 8 more
      

      Besides in the mojarra test-suite there is a cdi sample application that cannot be deployed in wildfly because of 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: