JSF 2.0 : managed bean x does not exist, Check that appropriate getter and/or setter methods exist

Problem

In JSF 2.0, while using the @ManagedProperty annotation to DI the bean into the field of another bean,

HelloBean.java

@ManagedBean
@SessionScoped
public class HelloBean implements Serializable {
 
	@ManagedProperty(value="#{message}")
	private MessageBean messageBean;

MessageBean.java

@ManagedBean(name="message")
@SessionScoped
public class MessageBean implements Serializable {

It hits the following error message.

An Error Occurred:
Unable to create managed bean helloBean. The following problems were found: – Property messageBean for managed bean helloBean does not exist. Check that appropriate getter and/or setter methods exist.

Solution

To inject the “messageBean” into the field of “helloBean”, the messageBean setter method must be supply.

HelloBean.java

@ManagedBean
@SessionScoped
public class HelloBean implements Serializable {
 
	@ManagedProperty(value="#{message}")
	private MessageBean messageBean;
 
	public void setMessageBean(MessageBean messageBean) {
		this.messageBean = messageBean;
	}

Done, the error message should be gone.

Tags :

About the Author

mkyong
Founder of Mkyong.com and HostingCompass.com, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.

Comments

  • Pingback: water ionizer plans()

  • Pingback: YouTube likes kopen()

  • Pingback: alkaline water machine()

  • Pingback: water ionizer()

  • Pingback: her og nu laan()

  • Pingback: parking()

  • Pingback: lan penge nu og her 18 ar()

  • Pingback: parking()

  • Pingback: fue()

  • Pingback: tvpackages.net()

  • Pingback: tvpackages.net()

  • Pingback: Large arse fledgling blonde girlfriend krystal analyzed and nutted on()

  • Pingback: Blue Coaster33()

  • jerald

    Dear Mykong,
    I am getting the error.
    Unable to create managed bean employee. The following problems were found: – Managed bean class com.taurus.model.Employee for managed bean employee doesnt declare a public no-argument constructor. – Managed bean class com.taurus.model.Employee for managed bean employee doesnt declare a public no-argument constructor.
    Please advice.

    Thanks
    Jerry

  • Sary Al-Assad

    Thanks man. That helped.

  • cesar

    Dear mkyong.
    I did a search in google and after some time I find this page with this simple and direct explanation.
    Congratulations, very nice information.

  • An Old Programmer

    Solved by you again. Obvious *after* seeing the explanation.
    I just want to thank you for all of your work here. When I am hunting problems, most of what shows up in Google is too simplistic, vague, or just not helpful. Whenever I see your site appear, I have expectations of finding a useful answer, or if not, at least other related useful information.
    I just want you to know that what you are doing is appreciated.

    • http://www.mkyong.com mkyong

      Thanks for your kind comments :)

  • Pingback: Injecting Managed beans in JSF 2.0()