我有一个针对WebSphere Application Server 8的JSF项目,我尝试使用CDI概念。我有一个/WEB-INF/beans.xml
,如:
在JSF项目中,您需要什么CDI功能?
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee " title="http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">" class="link">http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> (http://java.sun.com/xml/ns/javaee/beans_1_0.xsd)
</beans>
这是我管理的bean:
@ConversationScoped
@Named("systemParameter")
public class SystemParameter implements Serializable {
@EJB
private ConfigFacade parameterFacade;
下面是从XHTML页面片段:
<h:commandButton action="#{systemParameter.doSave}"/>
如果我试着点击按钮,我收到以下异常。
javax.el.PropertyNotFoundException: /systemParameters.xhtml at line 99 and column 99 action="#{systemParameter.doSave}": Target Unreachable, identifier 'systemParameter' resolved to null
我还需要什么?
你是否已经仔细检查了托管bean中的导入,以确保导入CDI注释? – vcetinick
@vcetinick是:-)'import javax.annotation.PostConstruct; import javax.ejb.EJB; import javax.enterprise.context.ConversationScoped; import javax.inject.Named;' – Kayser
Java区分大小写。 'Beans.xml'与'beans.xml'不一样。文件位置也很重要,但您没有透露任何信息。内容实际上并不重要(它可以保持为空),但是您已经显示了一些奇怪的节点值。 – BalusC