I defined viewParam to process a GET request but the session bean is null.
/treeTable2.xhtml @28,119 value="#{conformanceProfileController.dataValueAssertionController.library_line}": Target Unreachable, identifier 'conformanceProfileController' resolved to null
GET request:
treeTable2.jsf?category=Message
XHTML code
<f:metadata>
<f:viewParam name="category" value="#{conformanceProfileController.category}" />
</f:metadata>
The Bean
@ManagedBean
@SessionScoped
public class ConformanceProfileController implements Serializable {
private String category;
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
}
My development server is Tomcat 7.0 and I use Mojarra 2.1.0
EDIT: I created a simplified version with a new page and new bean. The code in the post is the same as the one on my machine.
XHTML Code:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
>
<h:head>
</h:head>
<f:metadata>
<f:viewParam name="category" value="#{myBean.category}" />
</f:metadata>
<h:body>
</h:body>
</html>
MyBean:
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean
@SessionScoped
public class MyBean implements Serializable {
private String category;
public MyBean() {
System.out.println("Creation");
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
}
The GET request: treeTable3.jsf?category=Message
The error message: /treeTable3.xhtml @8,60 value="#{myBean.category}": Target Unreachable, identifier 'myBean' resolved to null
Mojarra 2.1.0 do not work in Tomcat/Jetty due to a bug in annotation scanning. Upgrade to at least 2.1.1 or the current 2.1.3.
This has nothing to do with view parameters or session scoped beans. It will just fail in all cases where you expect a
@ManagedBean.