Tt sounds suspicious that the listener hadn't worked for you. It should've worked. What I assume has happened is that you expect your request-scoped beans to get their dependencies injected outside a request/response cycle. Well, this won't happen.
So you'd better do one of these:
- put the
@PostConstruct
annotation on every bean and initialize it.
- register a
ServletRequestListener
which gets triggered on each request
If you want a managed bean to initialize something application-wide (what is that something, btw):
- Create a managed bean with scope
application
- Do your initialization in a method annotated with
@PostConstruct
Btw, you have been wrong to put JSP initialization code in constructor. It should've been in the init(..)
method. (and actually, shouldn't have been in a JSP at all)
Alternatively you can use a PhaseListener
(in the faces-config.xml
), where to lazily load tha application settings.