Jsf 尝试在Glassfish 4上使用CDI会导致javax.el.PropertyNotFoundException:Target unreable,identifier';indexMB';已解析为空

Jsf 尝试在Glassfish 4上使用CDI会导致javax.el.PropertyNotFoundException:Target unreable,identifier';indexMB';已解析为空,jsf,primefaces,glassfish,cdi,Jsf,Primefaces,Glassfish,Cdi,我在一个页面上遇到一个错误,唯一的错误发生在我单击SUBMIT按钮之后 javax.el.PropertyNotFoundException:无法访问目标,标识符“indexMB”解析为null 我遵循了该主题的建议,但没有帮助我 任何帮助都是非常有用的 按照我的设置和我的文件进行操作: 玻璃鱼4 Primefaces 3.5 commons文件上传1.3 通用io 2.4 index.xhtml <f:loadBundle basename="i18n" var="bundle" /

我在一个页面上遇到一个错误,唯一的错误发生在我单击SUBMIT按钮之后

javax.el.PropertyNotFoundException:无法访问目标,标识符“indexMB”解析为null

我遵循了该主题的建议,但没有帮助我

任何帮助都是非常有用的

按照我的设置和我的文件进行操作:

  • 玻璃鱼4
  • Primefaces 3.5
  • commons文件上传1.3
  • 通用io 2.4
index.xhtml

<f:loadBundle basename="i18n" var="bundle" />
<h:head>
    <title>#{bundle['index_title']}</title>
</h:head>
<h:body>
    #{bundle['index_appname']}
    <br />
    <h:form id="frmIndex">
        <p:panelGrid columns="2">
            <p:outputLabel for="user" value="#{bundle['lblUser']}" />
            <p:inputText id="user" value="#{indexMB.user}" />

            <p:outputLabel for="password" value="#{bundle['lblPassword']}" />
            <p:password id="password" value="#{indexMB.password}" />
        </p:panelGrid>
        <p:commandButton action="#{indexMB.loginTest}" value="#{bundle['btn_login']}" />
    </h:form> 
</h:body>
原木(玻璃鱼)

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 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 http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>faces/index.xhtml</welcome-file>
    </welcome-file-list>
</web-app>
<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.2"
        xmlns="http://xmlns.jcp.org/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">

    <application>
        <locale-config>
            <default-locale>pt_BR</default-locale>
            <supported-locale>en</supported-locale>
            <supported-locale>fr</supported-locale>
        </locale-config>
    </application>
</faces-config>
<?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 http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>
beans.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 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 http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>faces/index.xhtml</welcome-file>
    </welcome-file-list>
</web-app>
<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.2"
        xmlns="http://xmlns.jcp.org/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">

    <application>
        <locale-config>
            <default-locale>pt_BR</default-locale>
            <supported-locale>en</supported-locale>
            <supported-locale>fr</supported-locale>
        </locale-config>
    </application>
</faces-config>
<?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 http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>

您的bean实际上不是CDIBean,我想您的问题是由于混淆了导入造成的。所以试试看

 @javax.inject.Named //defaults to "indexMB"
 @javax.enteprise.context.RequestScoped
 public class IndexMB {
      //rest of your class here
 }

您的bean实际上不是cdibean,我想您的问题是由于混淆了导入。所以试试看

 @javax.inject.Named //defaults to "indexMB"
 @javax.enteprise.context.RequestScoped
 public class IndexMB {
      //rest of your class here
 }

我没有看到CDI在这里真正发挥作用。尽管如此,您在哪里导入
@ManagedBean
@RequestScoped
beanI在这里看不到CDI真正发挥作用的地方。尽管如此,您在何处导入
@ManagedBean
@RequestScoped
beanI将“@ManagedBean”更改为“@Named”,并且成功了。谢谢我将“@ManagedBean”改为“@Named”,效果很好。谢谢