How to inject FacesContext with JSF 2.3 and TomEE?

余生长醉 提交于 2019-12-11 07:33:08

问题


I've been trying to use JSF 2.3 with TomEE server and I'm having problems using the @Inject annotation with the FacesContext object.

When I use it, i get the following exception while starting my TomEE server:

SEVERE: CDI Beans module deployment failed 
org.apache.webbeans.exception.WebBeansDeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Api type [javax.faces.context.FacesContext] is not found with the qualifiers 
Qualifiers: [@javax.enterprise.inject.Default()]

Am I missing something? Thanks.


回答1:


Seems like some JSF2.3 features must be activated by setting the used JSF version.

Try setting JSF version by adding this empty class:

    import javax.faces.annotation.FacesConfig;

/**
 * The presence of the @FacesConfig annotation on a managed bean deployed within an application enables version specific
 * features. In this case, it enables JSF CDI injection and EL resolution using CDI.
 *
 */
@FacesConfig(version = FacesConfig.Version.JSF_2_3)
public class ConfigurationBean {
}

from https://github.com/javaee/glassfish/issues/22094



来源:https://stackoverflow.com/questions/45846590/how-to-inject-facescontext-with-jsf-2-3-and-tomee

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!