1

I have a bean that I configured to be application scoped in faces-config.xml as below:

<managed-bean eager="true">
    <managed-bean-name>communicationCRCList</managed-bean-name>
    <managed-bean-class>com.ingdirect.edeal.bean.CommunicationCRCListBean</managed-bean-class>
    <managed-bean-scope>application</managed-bean-scope>
</managed-bean>

That been is loaded when the app starts by the call of the INIT() method on a different class. The app starts, the class is loaded and create the bean calling the init method. As it's an application scoped bean, it should be accessible from everywhere. In my case, I would like to get that bean in a servlet. I read that all the application scoped managed beans are loaded in the servletContext. In order to get that bean, I tried the following in my servlet:

CommunicationCRCListBean CommunicationCrcListBean = (CommunicationCRCListBean) getServletContext().getAttribute(COMMUNICATION_LIST_CRC_BEAN);

For information, COMMUNICATION_LIST_CRC_BEAN = communicationCRCList--> name of the bean. Unfortunatly, I get null....

I can't figure out what's wrong... Does somebody has an idea ?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Hubert Solecki
  • 2,611
  • 5
  • 31
  • 63

0 Answers0