File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Why is my faces-config.xml session bean not appearing in the session? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Why is my faces-config.xml session bean not appearing in the session?" Watch "Why is my faces-config.xml session bean not appearing in the session?" New topic
Author

Why is my faces-config.xml session bean not appearing in the session?

Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Hi,

I'm using MyFaces 1.1.6. Does anyone know where JSF records what happens when it is trying to initialize a session bean? I have this code ...



but when my session starts up, it is nowhere to be found -- i.e. it does not appear in the session. I'm guessing an error occurred but I don't see anything in my stdout or stderr logs (I'm using JBoss 5.1 on Mac 10.5.6). Any ideas how I can figure out why my session bean is not getting created? - Dave
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15632
    
  15

You'd have to crank up the javax.faces logging level. But if you're really failing on bean instantiation, there should be a stacktrace. In vanilla tomcat that would be in the catalina.out or localhost logfiles. In JBoss, look in your server's log directory. I think the name is something like "server.log", so it's not hard to find.


Customer surveys are for companies who didn't pay proper attention to begin with.
Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Since I have defined this bean in the session scope, when should this bean actually be created and registered to the session? -
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15632
    
  15

Managed beans are created on demand. When a session is created, the session beans are not automatically created. However, if there is no session, then referencing a session bean in a JSF view will cause the session to be created, the session bean to be instantiated and the instantiated bean to be stored in the session.

The most important thing to bear in mind is that if you have non-JSF code, that means that a lookup of the session bean will return null until it has either been instantiated by being referenced in a JSF view or it is manually instantiated (and manually initialized) by non-JSF code. JSF Managed session beans are no different than any other session beans except for the fact that JSF will use information from faces-config to instantiate and initialize them, if needed.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why is my faces-config.xml session bean not appearing in the session?
 
Similar Threads
Managed-Bean question in JSF
managed bean injection problem
how to access a managed bean from a button action listener ?
Not creating managed bean
How do I initialize this managed property?