1

I have problem with bean discovery in JSF 2.3 and CDI application. I am using Glassfish 5.0, Java 8 (1.8.0_151). My files:

faces-config.xml

<?xml version='1.0' encoding='UTF-8'?>
<faces-config 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_3.xsd"
              version="2.3">


</faces-config>

LocaleBean:

import javax.enterprise.context.SessionScoped;
import javax.inject.Named;

@Named
@SessionScoped
public class LocaleBean implements Serializable {

}

Message in Glassfish log after submitting a form to this bean:

javax.el.PropertyNotFoundException: /home.xhtml @15,81 value="#{localeBean.language}": Target Unreachable, identifier 'localeBean' resolved to null

Form submit works only if I use imports listed bellow instead of @Named and @SessionScoped from javax.enterprise.context package.

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

But both are deprecated in JSF 2.3.

Any ideas guys? Thank you!

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Jan Novy
  • 11
  • 1
  • 1
  • 7
  • Possible duplicate of [Identifying and solving javax.el.PropertyNotFoundException: Target Unreachable](https://stackoverflow.com/questions/30128395/identifying-and-solving-javax-el-propertynotfoundexception-target-unreachable) – BalusC Nov 05 '17 at 13:51
  • I would say that it's more similar to: https://stackoverflow.com/questions/45682309/changing-faces-config-xml-from-2-2-to-2-3-causes-javax-el-propertynotfoundexcept Because of usage JSF 2.3 and CDI. – Jan Novy Nov 05 '17 at 15:56
  • Ah, `@ManagedBean` is out-dated (JSF 2.0). You need to use `@Named` instead. And watch out for proper `*Scoped` usage which seems to be the case. This is a common mistake by mixing JSF 2.2 and JSF 2.0 tags, they **are always** incompatible. – Roland Feb 12 '18 at 16:06

1 Answers1

0

I have found solution and its description in this topic on GitHub:

https://github.com/javaserverfaces/mojarra/issues/4264

Jan Novy
  • 11
  • 1
  • 1
  • 7