Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18009
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18009
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic