JEE6 CDI and JSF annotation hell

If you are in a JEE6 environment with CDI and JSF be very careful with choosing annotations. Always prefer the ones from javax.enterprise.context.* if there are also the same ones under javax.faces.. as JSF you surely run into troubles if you mix them. CDI annoteted beans are managed by the container and beans annotated with the annotations from faces are managed by the JSF container. E.g. this can result in SessionScoped beans that are initialized more than once for a single session.

Generally I think you should not use the @ManagedBean annotation in a JEE6 environment. I prefer @Named.

Leave a Comment