【发布时间】:2012-10-05 12:05:51
【问题描述】:
我有一个针对 WebSphere Application Server 8 的 JSF 项目,我尝试使用 CDI 概念。我有一个 /WEB-INF/beans.xml 喜欢:
<?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 页面的 sn-p:
<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 是的:-)
import javax.annotation.PostConstruct; import javax.ejb.EJB; import javax.enterprise.context.ConversationScoped; import javax.inject.Named; -
Java 区分大小写。
Beans.xml与beans.xml不同。文件位置也很重要,但你什么也没说。内容实际上无关紧要(可以保持为空),但是您显示了一些奇怪的节点值。 -
@BalusC 文件名是
beans.xml。该位置在 WEB-INF 下。 -
从 2003 年到 2008 年,我一直在使用 WebSphere 5.x/6.x。很高兴我不再使用那个奇怪的野兽了。
标签: java jsf-2 websphere java-ee-6 cdi