4 Replies Latest reply on Apr 11, 2014 5:58 AM by surendrand001

    Lazy loading Stateless session beans

    surendrand001 Newbie

      Hi,

      I am having a J2EE project with thousands of Stateless session beans. When ever I start my jboss server in my development environment it takes around 15 minutes to bring up my server. Time taken is mostly due to loading EJB Stateless, Entity and Message beans at the server start up.

       

      Is it possible to lazy load my Stateless & Entity bean's, so that it can be loaded only when required? so that I can bring down my start up time.

       

      Regards,

      Surendran

        • 1. Re: Lazy loading Stateless session beans
          Wolf-Dieter Fink Master

          Which server version do you use? What hardware and JVM?

           

          Only MDB's are started directly as they need to be able to handle requests.

          SLSB and Entities are initialized on demand if you use it, depend to the pool configuration it might be prefilled.

          What do you see that you come to the conclusion the loading is the reason for the slow start?

          • 2. Re: Lazy loading Stateless session beans
            surendrand001 Newbie

            I am using JBoss 4.2.2.GA .

             

            From the server & console log I can see that JBoss is spending most of time in following operation

             

            00:49:01,468 INFO  [EJBContainer] STARTED EJB: com.mycompany.MyBeanDaoA ejbName: MyBeanDaoA

            00:49:01,562 INFO  [EJBContainer] STARTED EJB: com.mycompany.MyBeanDaoB ejbName: MyBeanDaoB

            00:49:01,640 INFO  [EJBContainer] STARTED EJB: com.mycompany.MyBeanDaoC ejbName: MyBeanDaoC

            00:49:01,671 INFO  [EJBContainer] STARTED EJB: com.mycompany.MyBeanDaoD ejbName: MyBeanDaoD

            ..

            ..

            ...

            00:59:01,781 INFO  [EJBContainer] STARTED EJB: com.mycompany.MyBeanDaoE ejbName: MyBeanDaoE

             

            Almost all my beans are SLSB

            • 3. Re: Lazy loading Stateless session beans
              Wolf-Dieter Fink Master

              Hmm, not sure whether the pools are really prefilled. It takes only a few ms for each bean.

              Maybe your application is huge and the machine slow (or less memory) so the problem is here.

              Do you use EJB2 or EJB3?

               

              For EJB2 you might have a look to the standardjboss.xml "* Stateless SessionBean" configuration. There is a container-pool-conf, maybe MinimumSize and MaximumSize helps.

              • 4. Re: Lazy loading Stateless session beans
                surendrand001 Newbie

                I am using EJB3. On the fastest hardware I have it takes around 3-4 minutes (still its longer)

                 

                as per the logs

                 

                00:49:01,562 INFO  [EJBContainer] STARTED EJB: com.mycompany.MyBeanDaoB ejbName: MyBeanDaoB

                 

                I can see that EJB instances are loaded at the server startup.  can we postpone this operation till only when EJB is referred by my class?