I'm migrating a JSF 2.1 application to CDI. To be able to use the @javax.faces.bean.ViewScoped
annotation, I'm trying to use MyFaces CODI, as suggested here.
The application seems to be working as expected, but I noticed by logging that the constructor of each of my @Named
beans is called twice when I first access it. However, their init()
methods annotated with @PostConstruct
are only executed once.
When those beans are used for the second or nth time, their constructor is only called once as normally expected.
It doesn't happen as soon as I remove the MyFaces CODI jars from my app, so I'm sure it is caused by it.
Is this a normal behaviour, and if so, why? Does it have an impact on performance or could this cause any problem?
I'm feeling this could be linked with a proxy creation, but it's not 100% clear in my mind so I would greatly appreciate an explanation.
My configuration:
- JSF 2.1
- Mojarra 2.1.6
- MyFaces CODI 1.0.5 (tested with full bundle or core + JSF 2.0+)
- (unrelated: Primefaces 3.5 and Omnifaces 1.5)
- Glassfish 3.1.2, also tested on Jboss EAP 6.0 with the same results
Thanks.