尝试在Glassfish 4上使用CDI导致javax.el.PropertyNotFoundException:目标不可访问,标识符'indexMB'解析为null [英] Trying to use CDI on Glassfish 4 results in javax.el.PropertyNotFoundException: Target Unreachable, identifier 'indexMB' resolved to null

查看:92
本文介绍了尝试在Glassfish 4上使用CDI导致javax.el.PropertyNotFoundException:目标不可访问,标识符'indexMB'解析为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在单个页面上发生错误,并且在单击SUBMIT按钮后发生唯一错误。


javax.el .PropertyNotFoundException:目标不可达,标识符'indexMB'解析为null


我遵循主题JSF2表单提交目标无法访问,标识符'myModel'解析为空只提交,但没有帮助我。



任何帮助都将非常有用。



按照我的设置和我的文件:


  • Glassfish 4

  • Primefaces 3.5

  • commons-fileupload 1.3

  • commons-io 2.4



index.xhtml

 < f:loadBundle basename =i18nvar =bundle/ > 
< h:head>
< title>#{bundle ['index_tit乐]}< /标题>
< / h:头>
< h:body>
#{bundle ['index_appname']}
< br />
< h:form id =frmIndex>
< p:panelGrid columns =2>
< p:outputLabel for =uservalue =#{bundle ['lblUser']}/>
< p:inputText id =uservalue =#{indexMB.user}/>

< p:outputLabel for =passwordvalue =#{bundle ['lblPassword']}/>
< / p:panelGrid>
< / h:表格>
< / h:body>

IndexMB.java

  @ManagedBean(indexMB)
@RequestScoped
公共类IndexMB {

私有字符串密码;
私人字符串用户;
$ b $ public public IndexMB(){
}

public String loginTest(){
...
}

// getters and setters
}

log(Glassfish)

  javax.el.PropertyNotFoundException:/index.xhtml @ 18,66 value =#{indexMB.user}:Target Unreachable,identifier'indexMB '解析为null 
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100)
at org.primefaces.renderkit.InputRenderer.findImplicitConverter(InputRenderer.java:170)
at org.primefaces.renderkit.InputRenderer.findConverter(InputRenderer.java:190)
at org.primefaces.renderkit.InputRenderer.getConvertedValue(InputRenderer.java:196)
at javax.faces .component.UIInput.getConvertedValue(UIInput.java:1046)
位于javax.faces.component.UIInput.validate(UIInput.java:976)
位于javax.faces.component.UIInput.executeValidate(UIInput .java:1249)在javax.faces.component.UIInput.proce中为
(UIForm.java:253)
at javax.faces.component.UIForm.processValidators(UIForm.java:253)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
at javax.faces.component.UIForm.processValidators(UIForm.java:253)
在javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)在javax.faces.component.UIComponentBase.processValidators
(UIComponentBase.java:1261)
在javax.faces .component.UIViewRoot.processValidators(UIViewRoot.java:1195)
at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
at com.sun.faces.lifecycle.Phase .doPhase(Phase.java:101)
在com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
在javax.faces.webapp.FacesServlet.service(FacesServlet.java :646)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
在org .apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina .core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve .invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter的.java:260)在com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188

。在org.glassfish.grizzly.http.server.HttpHandler.runService (HttpHandler.java:191)在org.glassfish.grizzly.http.server.HttpHandler.doHandle
(HttpHandler.java:168)
在org.glassfish.grizzly.http.server.HttpServerFilter.handleRead (HttpServerFilter.java:189)org.gla
ssfish.grizzly.filterchain.ExecutorResolver $ 9.execute(ExecutorResolver.java:119)
在org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
在org.glassfish.grizzly .filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
在org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
在org.glassfish.grizzly.filterchain.DefaultFilterChain .process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport的.java:838)
处org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0 org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
(WorkerThreadIOStrategy.java:115 )
在org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access $ 100(WorkerThreadIOStr ategy.java:55)
在org.glassfish.grizzly.strategies.WorkerThreadIOStrategy $ WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
在org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker.doWork( AbstractThreadPool.java:564)
在org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker.run(AbstractThreadPool.java:544)
在java.lang.Thread.run(Thread.java:724)
。通过引起:javax.el.PropertyNotFoundException:目标不可达,识别符 'indexMB' 在com.sun.el.parser.AstValue.getTarget解析为空
(AstValue.java:174)
在com.sun.el.parser.AstValue.getType(AstValue.java:86)
在com.sun.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:201)
在org.jboss.weld .el.WeldValueExpression.getType(WeldValueExpression.java:93)
在com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:98)
... 43多个

web.xml

 <?xml version =1.0encoding =UTF-8?> 
< web-app version =3.0xmlns =http://java.sun.com/xml/ns/javaeexmlns:xsi =http://www.w3.org/2001/ XMLSchema-instancexsi: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>
<参数值>开发< /参数值>
< / context-param>
< servlet>
< servlet-name> Faces Servlet< / servlet-name>
< servlet-class> javax.faces.webapp.FacesServlet< / servlet-class>
<加载启动> 1< /加载启动>
< / 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>

faces-config.xml

 <?xml version ='1.0'encoding ='UTF-8'?> 
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 /网络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>

beans.xml

 <?xml version =1.0encoding =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真的不是CDI bean问题是由混淆进口引起的。因此,请尝试

  @ javax.inject.Named //默认为indexMB
@ javax.enteprise.context。 RequestScoped
public class IndexMB {
//这里的其余班级
}


I am getting an error on a single page, and the only error occurs after I click the SUBMIT button.

javax.el.PropertyNotFoundException: Target Unreachable, identifier 'indexMB' resolved to null

I followed the recommendations of the topic JSF2 form submit " Target Unreachable, identifier 'myModel' resolved to null ONLY on submit but did not help me.

Any help will be very useful.

Follow my setup and my files:

  • Glassfish 4
  • Primefaces 3.5
  • commons-fileupload 1.3
  • commons-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>

IndexMB.java

@ManagedBean ("indexMB")
@RequestScoped
public class IndexMB {

private String password;
private String user;

public IndexMB() {
}

public String loginTest(){
   ...
}

// getters and setters
}

log (Glassfish)

javax.el.PropertyNotFoundException: /index.xhtml @18,66 value="#{indexMB.user}": Target Unreachable, identifier 'indexMB' resolved to null
    at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100)
    at org.primefaces.renderkit.InputRenderer.findImplicitConverter(InputRenderer.java:170)
    at org.primefaces.renderkit.InputRenderer.findConverter(InputRenderer.java:190)
    at org.primefaces.renderkit.InputRenderer.getConvertedValue(InputRenderer.java:196)
    at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1046)
    at javax.faces.component.UIInput.validate(UIInput.java:976)
    at javax.faces.component.UIInput.executeValidate(UIInput.java:1249)
    at javax.faces.component.UIInput.processValidators(UIInput.java:712)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
    at javax.faces.component.UIForm.processValidators(UIForm.java:253)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
    at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1195)
    at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
    at java.lang.Thread.run(Thread.java:724)
    Caused by: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'indexMB' resolved to null
    at com.sun.el.parser.AstValue.getTarget(AstValue.java:174)
    at com.sun.el.parser.AstValue.getType(AstValue.java:86)
    at com.sun.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:201)
    at org.jboss.weld.el.WeldValueExpression.getType(WeldValueExpression.java:93)
    at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:98)
    ... 43 more

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>

faces-config.xml

<?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>

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 http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>

解决方案

Your bean is really not a CDI bean I guess your problem is caused by mixing up the imports. So try

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

这篇关于尝试在Glassfish 4上使用CDI导致javax.el.PropertyNotFoundException:目标不可访问,标识符'indexMB'解析为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆