• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 27919
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 27919
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
My cellmate was this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic