users@glassfish.java.net

Re: GF3.1 _at_Named annotation not working but _at_ManagedBean does

From: Jason Lee <jason.d.lee_at_oracle.com>
Date: Fri, 11 Mar 2011 17:21:40 -0600

Do you have a WEB-INF/beans.xml file?

On 3/11/11 5:12 PM, forums_at_java.net wrote:
> When I run the code like the following that is part of an entire program,
> consist of a Bean (the following code), a XHTML login page and another
> XHTML
> welcome page after login submission, I received an error after login page
> submisstion:
>
>
>
> HTTP Status 500 with exception: javax.servlet.ServletException:
> /login.xhtml
> @16,46 value="#{user.name}": Target Unreachable, identifier 'user'
> resolved
> to null.
>
>
>
> However after I changed @Name("user") to @ManagedBean(name="user"), the
> program runs without error. Is this due to a bug in GF3.1?
>
> Cheers, lchong2
>
>
>
> // UserBean
> import javax.enterprise.context.SessionScoped;
> import javax.inject.Named;
> @Named("user") //or @ManagedBean(name="user")
> @SessionScoped
> public class UserBean implements Serializable {
> private String name;
> private String password;
> public String getName() {
> return name;
> }
> public void setName(String name) {
> this.name = name;
> }
> public String getPassword() {
> return password;
> }
> public void setPassword(String password) {
> this.password = password;
> }
>
> }
>
>
> --
>
> [Message sent by forum member 'lchong2']
>
> View Post: http://forums.java.net/node/780709
>
>


-- 
Jason Lee
Senior Member of Technical Staff
GlassFish REST API / Administration Console
Oracle Corporation
Phone +1 405-216-3193
Blog http://blogs.steeplesoft.com