1 Reply Latest reply on May 2, 2010 7:12 AM by Nick Belaevski

    jsf begginer: session bean cannot be accessed from request bean

    m m Newbie

      I have BaseBean class that is inherited by other managed beans. In that class i have reference to session bean.

       

      class BaseBean {

         private MySessionBean session; // session bean

         getSession() { return session; }

         ...

      }

       

      class ResuestBean extends BaseBean {

         void RequestBean() {

             getSession(); // null !!!!!!

         }

      }

       

      I get error in my webapp because in some place getSession() return null. Why?

      How to ensure that MySessionBean will be created before all request beans and getSession always return not null ?

        • 1. Re: jsf begginer: session bean cannot be accessed from request bean
          Nick Belaevski Master

          Hi,

           

          If you are using managed beans, you should configure dependencies in faces-config.xml like the following:

           

           

           <managed-bean>
            <managed-bean-name>dfsBean</managed-bean-name>
            <managed-bean-class>org.richfaces.demo.datafilterslider.DemoSliderBean</managed-bean-class>
            <managed-bean-scope>session</managed-bean-scope>
            <managed-property>
             <property-name>demoInventoryList</property-name>
             <value>#{inventoryList}</value>
            </managed-property>
           </managed-bean>