JEE CDI tip: Target Unreachable, identifier resolved to null

If you are just starting out with JEE CDI (Weld), it’s easy to forget the required beans.xml file. If you don’t include it, you may run into problems like this:

SEVERE: javax.el.PropertyNotFoundException: /index.xhtml @8,67 action="#{crm.ping}": Target Unreachable, identifier 'crm' resolved to null
javax.faces.el.EvaluationException: javax.el.PropertyNotFoundException: /index.xhtml @8,67 action="#{crm.ping}": Target Unreachable, identifier 'crm' resolved to null
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:95)
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
    at javax.faces.component.UICommand.broadcast(UICommand.java:315)
...

The beans.xml file (in META-INF/classes or WEB-INF/) can be empty or contain the following:

<?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>
blog comments powered by Disqus