Fix JSF Target Unreachable Identifier Resolved to Null
Fix the Faces error where an expression cannot reach its target: check the bean name, scope imports, CDI discovery and nulls in the path.

A page that worked yesterday renders with an error, or a button does nothing and the log says:
jakarta.el.PropertyNotFoundException: /customers.xhtml @12,52 value="#{customerBean.customer.name}": Target Unreachable, identifier 'customerBean' resolved to nullor a variant:
jakarta.el.PropertyNotFoundException: Target Unreachable, 'customer' returned nullExpression language walks the path customerBean.customer.name one segment at a time. The error says which segment came back as null, and the wording tells you what kind of null. The expression syntax is in expression language and value binding, and the framework background in JSF and PrimeFaces for maintainers.
Form 1: "identifier 'customerBean' resolved to null"
The first segment is a name that EL looks up in the contexts (request, view, session, application, and CDI). Nothing was found. Check these in order.
The bean has no name
@RequestScoped
public class CustomerBean { } // CDI bean, but not visible to ELAdd @Named:
@Named
@RequestScoped
public class CustomerBean { }Without it, CDI knows the bean for injection and EL does not.
The default name is not what you typed
@Named on CustomerBean gives the name customerBean. EL names are case-sensitive: #{CustomerBean.name} and #{customerbean.name} are both unresolved. For a class like URLBean the default name stays URLBean, because two leading capitals disable decapitalization. Set it explicitly with @Named("customers") when in doubt.
The scope annotation is from the wrong package
import jakarta.faces.bean.RequestScoped; // removed in Faces 4.0The managed bean annotations were deprecated in Faces 2.3 and removed in Faces 4.0, so this import fails to compile on a current runtime, or compiles against an old library and does nothing. Use jakarta.enterprise.context.RequestScoped and, for view scope, jakarta.faces.view.ViewScoped. See managed beans vs CDI beans.
CDI does not see the class
In a WAR, CDI needs the class to have a bean-defining annotation (a scope) in the default annotated discovery mode, or a beans.xml with bean-discovery-mode="all". A bean in a library jar needs the library to be a bean archive. A class in a package that the scanner excludes, or a server without CDI enabled (a plain Tomcat), never creates the bean. On Tomcat you must add a CDI implementation such as Weld.
Form 2: "'customer' returned null"
The bean exists and a property in the middle of the path is null:
@Named
@ViewScoped
public class CustomerBean implements Serializable {
private Customer customer; // never set
public Customer getCustomer() { return customer; }
}#{customerBean.customer.name} cannot go through a null object. Initialize it:
private Customer customer = new Customer();or in @PostConstruct after loading the entity from a request parameter. If the object is loaded from a <f:viewParam>, remember that the parameter is applied later than @PostConstruct, and use <f:viewAction> to load after binding.
Inspect what EL sees
Print the names that exist:
@Inject BeanManager beans;
public void dump() {
beans.getBeans(Object.class, new AnnotationLiteral<Any>() {}).stream()
.map(Bean::getName).filter(Objects::nonNull).sorted().forEach(System.out::println);
}If your name is absent, the bean was not discovered.
A checklist that finds the cause in order
The message has two shapes, and the cause is almost always one of five things. Work through the list in this order, because each step is cheaper than the next.
- Is the name in the page the name of the bean? A bean annotated
@Namedwithout a value is named from its class, with the first letter lowered:CustomerBeaniscustomerBean. A bean namedCustomeriscustomer, and#{Customer.name}finds nothing. - Does the class carry
@Named? Since Faces 4 removed the old managed bean facility, a class with@ManagedBeanis no longer a bean at all, and the page's reference resolves to null. - Does the scope annotation come from the right package?
jakarta.faces.view.ViewScopedandjakarta.enterprise.context.RequestScopedare right;jakarta.faces.bean.ViewScopedis the removed one. An import of the wrongViewScopedcompiles when an old API jar is on the classpath, and fails at run time. - Does CDI discover the class? The archive needs a
beans.xml, or an annotated bean in an archive withbean-discovery-mode="annotated", and the class must be inside the deployment, not in an unscanned library. - Is the second form the problem?
Target Unreachable, 'customer' returned nullmeans the bean exists and the property is null, so the code that fills it did not run or ran too late.
import jakarta.enterprise.context.RequestScoped; // not javax, not jakarta.faces.bean
import jakarta.inject.Named;
@Named
@RequestScoped
public class CustomerBean {
private Customer customer = new Customer(); // initialise it, so #{customerBean.customer.name} is reachable
public Customer getCustomer() { return customer; }
public void setCustomer(Customer customer) { this.customer = customer; }
}The initialiser on customer matters for the second form. A page that binds #{customerBean.customer.name} to an input needs the object to exist before the first request that submits the form, because JSF will not create it for you. A null property gives Target Unreachable, 'customer' returned null.
Ask the EL resolver directly
When the checklist does not settle it, ask the same machinery the page uses. A small diagnostic page or a test evaluates an expression and reports what it resolves to.
public String describe(String expression) {
FacesContext ctx = FacesContext.getCurrentInstance();
try {
Object value = ctx.getApplication().evaluateExpressionGet(ctx, expression, Object.class);
return expression + " -> " + (value == null ? "null" : value.getClass().getName());
} catch (Exception e) {
return expression + " -> " + e.getClass().getSimpleName() + ": " + e.getMessage();
}
}Evaluating #{customerBean} tells you whether the bean resolves at all, and #{customerBean.customer} tells you whether the property is set. An answer of null for the first points to the naming and discovery steps, and an answer of null for the second points to the initialisation. The CDI container can list its beans too: inject BeanManager and call getBeans("customerBean"); an empty set means CDI does not know the name.
Fix the discovery when the class is right
If the class looks correct and the bean is still missing, the deployment is the cause. A web archive needs WEB-INF/beans.xml unless the server enables implicit discovery, and a bean in a dependency jar needs that jar to contain META-INF/beans.xml. The file can be nearly empty.
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee" version="4.0" bean-discovery-mode="annotated"/>With annotated, only classes that carry a bean-defining annotation, @Named alone is not one, become beans, so add a scope. A @Named class with no scope annotation is not discovered in this mode, which explains one more "resolved to null". Use @Dependent if you want the default scope, and prefer an explicit one.
Prevent it with a startup check
A bean that fails to resolve is found only when a user opens the page. A small test that renders the main pages in a container turns the mistake into a build failure. With a Faces-aware integration test tool, request each view and fail on any Target Unreachable or Property Not Found message in the log, then keep the test in the pipeline. A cheaper variant is a CDI check at startup that asks the BeanManager whether each name used by the pages exists.
@Test
void everyNamedBeanReferencedByPagesExists(BeanManager beans) {
for (String name : List.of("customerBean", "orderListBean", "loginBean")) {
assertThat(beans.getBeans(name)).as("bean " + name).isNotEmpty();
}
}Maintain the list by generating it from the pages with a search for #{ expressions, and review it when a bean is renamed. A rename in Java that is not mirrored in the XHTML is the commonest source of this error after a refactoring.
Where this does not apply
If the property exists and a getter is missing, the error is "Property not found" with the property name. If the problem only occurs on a postback and not on the first render, the bean is in a scope that has ended, as in view expiry. The Jakarta Expression Language specification defines the resolution order, and Jakarta Contexts and Dependency Injection defines @Named.


