ManagedBeanCreationException – What’s gone wrong now!

I recently failed to inject a managed bean into another bean that I was writing and for the life of me I couldn’t see what I’d done wrong. As is often the case it’s the little things that trip us up and in this case I was so used to doing it I couldn’t see the mistake. The exception message I was getting was:

Property foo for managed bean fooConverter does not exist.  Check that appropriate getter and/or setter methods exist.

Now that I read it in the cold light of day it’s actually quite a good exception message.

What I was trying to do was inject the applications main data handling managed bean into a converter which was also marked as a managed bean so that it would act as an injection point. The interesting bit of the code looked like this:

@ManagedBean(name = "fooConverter")
public class FooConverter implements Converter {
    @ManagedProperty(value = "#{foo}")
    private FooUpdate foo;

The ManagedBean annotations are correct and the ManagedProperty annotation is correct, what I’d forgotten was to supply a getter and, importantly, setter method for the foo property so the system was unable to set the value at injection time.