Skip to main content

JSF 2.0: ManagedBean not quite there...

3 replies [Last post]
Joined: 2008-12-31

I'm still engaged in my test JSF 2 application; same one I referred to in a prior thread. Most things are working out fine.

As an aside there are odd quirks. For example, System.out.println's in the handleNavigation method of a custom NavigationHandler do not print out, although the method is indisputably being called, and is correctly doing its thing. This had (has) me baffled. :-) No indication of any standard stream redirection in the 2.0.0-PR source, so who knows?

In any case, the curiosity at hand is this. I have 2 managed beans (@ManagedBean), both request scope (@RequestScoped), both having one method and several regular properties, and each having one managed property (@ManagedProperty). Both also have a @PostConstruct initialization method. There is nothing in the faces-config.xml except for a different navigation handler.

Both managed beans must be instantiated when you call associated Facelets pages, because of value bindings. One of the managed beans is operating just fine - I can see that from the page, but also because of printouts in its constructor and @PostConstruct method.

However, the other managed bean (judging by the System.out.println's in its ctor and @PostConstruct) never gets instantiated at all. However, the association between the EL variable and the managed bean has been correctly made, as per:

javax.el.PropertyNotFoundException: /main/welcome.xhtml @14,77 value="#{welcome.version}": The class 'org.ahs.beans.WelcomeBean' does not have the property 'version'.

So pretty clearly the @ManagedBean annotation on this troublesome class did get processed.

I've also varied the order in which I access these pages. It makes no difference.

I'm hoping there's something very obvious causing this. I've been staring at it too much; near as I can tell these are identically set up beans (except for the fact that the successful one also has a working @EJB injection happening).

Arved Sandstrom

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2009-03-24

I am facing exactly the same problem while accessing one managed bean from another managed bean.
I am using the Glassfish V3 Preview promoted build. Doesn't it contain the latest jars?

Joined: 2003-06-06

It depends - have you run the updatetool on the Preview build?

Joined: 2008-12-31

This particular problem went away when using jsf-api.jar and jsf-impl.jar produced by building from the Mojarra-2.0.0-PR-sources project. Now the other managed bean works as well.

A bit mysterious...I would have figured that the JARs from mojarra-2.0.0-PR were functionally identical to those produced from sources. I don't expect the sizes to be the same, however they are very close (I used jdk1.6.0_10 to compile).

Other problems (re taglib , Issue #909) still exist.