1

A really simple question, but one i can not get worked out,

My xhtml page have

                <p:commandButton action="#{NaviagationBean.buttonToUploadText}" value="Submit" icon ="ui-icon-arrowstop-1-n"/>

and i want to call code from my NavigationBean.java stored in richard.fileupload to call this code :

    public String buttonToUploadText() {
    System.out.println("buttonToUploadText invoked");
    return "/upload/uploadText.xhtml";
}

basically what action in my xhtml do you i need to call ? to call this ?

as the code atm shows up this error :

   WARNING: #{NavigationBean.buttonToUploadText}: javax.el.PropertyNotFoundException: /GUI/index.xhtml @61,130 action="#{NavigationBean.buttonToUploadText}": Target Unreachable, identifier 'NavigationBean' resolved to null
javax.faces.FacesException: #{NavigationBean.buttonToUploadText}: javax.el.PropertyNotFoundException: /GUI/index.xhtml @61,130 action="#{NavigationBean.buttonToUploadText}": Target Unreachable, identifier 'NavigationBean' resolved to null
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
    at javax.faces.component.UICommand.broadcast(UICommand.java:315)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:722)
Caused by: javax.faces.el.EvaluationException: javax.el.PropertyNotFoundException: /GUI/index.xhtml @61,130 action="#{NavigationBean.buttonToUploadText}": Target Unreachable, identifier 'NavigationBean' resolved to null
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:95)
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
    ... 36 more
Caused by: javax.el.PropertyNotFoundException: /GUI/index.xhtml @61,130 action="#{NavigationBean.buttonToUploadText}": Target Unreachable, identifier 'NavigationBean' resolved to null
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:107)
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
    ... 37 more

EDIT

it works fine when i do :

                <p:commandButton action="#{userBean.buttonToUploadText}" value="Submit" icon ="ui-icon-arrowstop-1-n"/> 

with the code in UserBean.java

the stack trace is :

WARNING: #{NavigationBean.buttonToUploadText}: javax.el.PropertyNotFoundException: /GUI/index.xhtml @61,130 action="#{NavigationBean.buttonToUploadText}": Target Unreachable, identifier 'NavigationBean' resolved to null
javax.faces.FacesException: #{NavigationBean.buttonToUploadText}: javax.el.PropertyNotFoundException: /GUI/index.xhtml @61,130 action="#{NavigationBean.buttonToUploadText}": Target Unreachable, identifier 'NavigationBean' resolved to null
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
    at javax.faces.component.UICommand.broadcast(UICommand.java:315)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:722)
Caused by: javax.faces.el.EvaluationException: javax.el.PropertyNotFoundException: /GUI/index.xhtml @61,130 action="#{NavigationBean.buttonToUploadText}": Target Unreachable, identifier 'NavigationBean' resolved to null
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:95)
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
    ... 36 more
Caused by: javax.el.PropertyNotFoundException: /GUI/index.xhtml @61,130 action="#{NavigationBean.buttonToUploadText}": Target Unreachable, identifier 'NavigationBean' resolved to null
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:107)
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
    ... 37 more

EDIT 2:

                <p:commandButton action="#{NaviagationBean.buttonToUploadText()}" value="Submit" icon ="ui-icon-arrowstop-1-n" ajax="False"/> 

gives me the same stacktrace but now takes me to a page where javax.el.PropertyNotFoundException: /GUI/index.xhtml @61,146 action="#{NaviagationBean.buttonToUploadText()}": Target Unreachable, identifier 'NaviagationBean' resolved to null

user1924104
  • 891
  • 2
  • 16
  • 38
  • You wrote the wrong name: `#{NaviagtionBean.buttonToUploadText}` must be `#{NavigationBean.buttonToUploadText}`. Check your writing. – Luiggi Mendoza Feb 02 '13 at 18:17
  • Thanks tried that but still get the same error :( – user1924104 Feb 02 '13 at 18:20
  • After fixing the misspelling, clean your project, compile it and deploy it again, just to make sure the changes were committed. – Luiggi Mendoza Feb 02 '13 at 18:21
  • Yep done that, even closed down netbeans and the browser, same issue, but when i put the code into userBean.java it works fine :S – user1924104 Feb 02 '13 at 18:24
  • Undeploy the project from Tomcat or GlassFish v3, then deploy it again. It happens sometimes. – Luiggi Mendoza Feb 02 '13 at 18:26
  • Still getting the same error sadly :( – user1924104 Feb 02 '13 at 18:30
  • Can you post the new stacktrace of the error? – Luiggi Mendoza Feb 02 '13 at 18:32
  • try agin by changing like this #{NaviagationBean.buttonToUploadText} to #{NaviagationBean.buttonToUploadText()} – Dipak Feb 02 '13 at 18:38
  • thanks i just tried that and now i get taken to a page where it says error occurred `javax.el.PropertyNotFoundException: /GUI/index.xhtml @61,146 action="#{NaviagationBean.buttonToUploadText()}": Target Unreachable, identifier 'NaviagationBean' resolved to null` i still get the same stacktrace – user1924104 Feb 02 '13 at 18:40
  • did you try to invoke simple alert by some other function in the same bean? Please try it by a p:command button, and still you getting same exception, add a name annotation for bean class , and use that name to invoke methode in it. – Dipak Feb 02 '13 at 18:45
  • Like @Named("myBean") on top of @session annotation of bean class. and call methods by myBean.Navigation(), i think this will help you. – Dipak Feb 02 '13 at 18:46

1 Answers1

3

The message Target Unreachable, identifier 'NavigationBean' resolved to null means that JSF framework can't find your managed bean. Make sure you have written your bean as follows:

@ManagedBean(name="NavigationBean")
@RequestScope
public class NavigationBean {

    public NavigationBean() {
    }

    public String buttonToUploadText() {
        System.out.println("buttonToUploadText invoked");
        return "/upload/uploadText.xhtml";
    }

    //other methods...
}

Or if you use CDI

@Named("NavigationBean")
@RequestScope
public class NavigationBean {

    //...
}

Another solution would be to use navigationBean instead of NavigationBean in EL:

<p:commandButton action="#{navigationBean.buttonToUploadText}" value="Submit"
    icon ="ui-icon-arrowstop-1-n" /> 
Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
  • Thank you this has solved it, but it has brought another issue, http://stackoverflow.com/questions/14665104/primefaces-command-buttons-stopping-fileupload-when-ajax-is-on – user1924104 Feb 02 '13 at 18:52