Application scoped beans are placed in the application scope of the underlying context.
Assuming that your JSF app runs on top of Servlet context, then the application scoped beans are just set as attributes of ServletContext.
In a Listener you just have access to the ServletContext. Place the application scoped bean in there with the managed bean name as attribute name.
The JSF context is not some sort of ongoing environment or control program. It's created by the JSF Servlet when a JSF-mapped URL is received, used to invoke the JSF resources, then discarded once the response has been sent back to the client. So there's nothing there for you to worry about.
JSF beans are no different than non-JSF beans, except that the JSF servlet may have created and initialized them using the specifications in faces-config rather than having the job done by explicit application logic. All this is very good, since it means that you can use JSF to do what JSF does best, while still being able to use raw JSPs, servlets, and even other frameworks such as Struts in the same webapp.
You're on the right track. If you create what I call a "null servlet" - a servlet with an init() method, but no get/post handlers, you can construct the application-scope bean in the init() method and store it in the application context. JSF will then be able to use - just define a managed bean with the name name that you stored it under in your servlet. Actually, lack of get/post logic is optional, but it's not used for the specific purpose of constructing the app-scope bean. Also make sure you configure web.xml to auto-start the servlet.
Customer surveys are for companies who didn't pay proper attention to begin with.
A simple solution that I have found in the book "JavaServer Faces 2.0: The Complete Reference" (Burns & Schalks, 2010), in the page 272, is to use the "eager" attribute on the ManagedBean annotation, for example:
in the page 273 it says "This attribute advises the JSF runtime that this bean instance ... must be
instantiated at startup time, before the container has served any requests"
If you want to reach the stars, then divide and conquer
Technically, you just woke a zombie, carlo, but considering the context, we'll forgive you
I ran off and checked the JavaDocs. What you said was true, but there is a little "asterisk clause" that does with it:
Oracle JavaDocs wrote:
If the value of the eager() attribute is true, and the managed-bean-scope value is "application", the runtime must instantiate this class when the application starts. This instantiation and storing of the instance must happen before any requests are serviced. If eager is unspecified or false, or the managed-bean-scope is something other than "application", the default "lazy" instantiation and scoped storage of the managed bean happens.
subject: How do you preload a JSF application scope bean?