Details
-
Type:
Bug
-
Status: Resolved (View Workflow)
-
Priority:
Major
-
Resolution: Done
-
Affects Version/s: 3.0.1
-
Fix Version/s: 3.1.0.Beta2
-
Component/s: Validation & Conversion
-
Labels:None
-
Environment:Tomcat 7.0.8, MyFaces 2.0.5, Weld 1.1.0
-
Affects:Compatibility/Configuration
Description
@Inject doesn't work for validators when using MyFaces. The fields are always null.
If I run the application with Mojarra instead of MyFaces everything works fine.
I'm note completely sure if it is a Seam Faces or a MyFaces issue.
Gliffy Diagrams
Issue Links
- relates to
-
WELD-913
SeamApplicationWrapper doesn't implement setApplication() correctly
-
- Closed
-
I did some more research on this. Actually this seems to be a bug in Weld 1.1.0 and not in Seam Faces. Let me explain:
SeamApplicationWrapper waits for the PostConstructApplicationEvent and then obtains the ApplicationFactory from the FactoryFinder. Then it calls ApplicationFactory.setApplication() to install the Seam Faces wrapper.
With MyFaces the SeamApplicationWrapper gets the WeldApplicationFactory from the FactoryFinder. Unfortunately SeamApplicationWrapper ignores calls to setApplication() and simply delegates them to the underlying ApplicationFactory. The problem here is that SeamApplicationWrapper already holds a reference to the Application instance that it returns for getApplication() and doesn't update this reference when setApplication() is called. Therefore SeamApplicationWrapper will return the old Application instance on future calls to getApplication().
See the code of WeldApplicationFactory:
https://github.com/weld/core/blob/master/environments/servlet/core/src/main/java/org/jboss/weld/environment/servlet/jsf/WeldApplicationFactory.java
For Mojarra the situation is a bit different. When using Mojarra Seam Faces calls setApplication() on Mohjarra's InjectionApplicationFactory, which wraps SeamApplicationWrapper. As InjectionApplicationFactory implements setApplication() correctly, the bug doesn't occur on Mojarra.
Does this sound reasonable? If you agree to my explanation I could open a ticket for Weld regarding this.