PropertyNotFoundException: Target Unreachable, identifier "" resolved to null

Splash Forums PrettyFaces Users PropertyNotFoundException: Target Unreachable, identifier "" resolved to null

This topic contains 3 replies, has 2 voices, and was last updated by  Christian Kaltepoth 4 years, 10 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #18511

    Hi, I am using PrettyFaces + JSF 2.0 and I am having an issue regarding <action>#{action}</action> usage.

    In my bean, if I use JEE annotation meaning @Named @RequestScope, the action is invoked without any problem.

    When try to switch to use JSF annotation meaning @ManagedBean @RequestScope, application throws an exception. Is it true that I must use JEE annotation?

    Caused by: javax.el.PropertyNotFoundException: Target Unreachable, identifier ‘listingContentController’ resolved to null

    at org.apache.el.parser.AstValue.getTarget(AstValue.java:98)

    at org.apache.el.parser.AstValue.invoke(AstValue.java:244)

    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)

    at com.ocpsoft.pretty.faces.util.FacesElUtils.invokeMethod(FacesElUtils.java:70)

    at com.ocpsoft.pretty.faces.util.FacesElUtils.invokeMethod(FacesElUtils.java:62)

    #22779

    No, both ways of declaring the bean should work. Seems like there is something wrong with your setup. Are you using the correct @RequestScoped? There is a CDI and a JSF version of that annotation. And does invoking action methods on that bean work when clicking a h:commandButton or something like that?

    BTW: It is very uncommon to migrate from CDI to JSF annotations. The @ManagedBean annotation was a very bad idea and I recommend everyone to move to CDI managed beans instead. So why are you migrating from CDI to JSF annotations?

    #22780

    Actually, I am not trying to migrate. I am just playing with different combinations. Thank you for your help.

    Since we touched the topic, I do have 1 question if you don’t mind. It is regarding the @RequestScope and @Scope(“request”)

    I am using JSF 2 + Spring framework. It seems like the @RequestScoped does not work as a new bean per request. I have to end up using Spring annotation @Scope(“request”). However in the Spring world, there is no view scope thing which can be useful in Ajax. My question sould be if it is right approach to go with all Spring scope annotation if spring is the selected IOC?

    Thank you.

    #22781

    The annotation you have to use to specify the scope of a bean depends on IoC container you are using to manage the bean. As the IoC container is responsible to manage the lifecycle of the bean instances, you must of cause use an annotation that the container understands.

    * If you are using plain JSF and @ManagedBean, you have to choose JSF’s @RequestScoped.

    * If you are using CDI with JSF, you have to use @Named and CDI’s @RequestScope (different package than the corresponding JSF annotation).

    * If you are using JSF with Spring (as in your case), you have to use something like @Component and @Scope(“something”).

    So it is correct that @RequestScoped doesn’t work for Spring beans.

    There are typically ways to simulate the view scope with other IoC containers. With CDI for example you could use Seam Faces or MyFaces CODI which both provide an implementation of @ViewScoped.

    I don’t know what the common pattern is to use the view scope in Spring applications. But there was a blog post by Cagatay Civici some time ago regarding this:

    Porting JSF 2.0’s ViewScope to Spring 3.0

    The post is very old. Perhaps there are easier ways to do this today. :)

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Comments are closed.