4 Replies Latest reply on Jun 30, 2015 11:25 PM by masummymesingh

    Why use EJB3 ?


      Hi all ,


      I have confusion that why use EJB over cdi .


      From clustering , production specific is there any advantage of Using EJB ? 


      Any one , who have real life application experience , please give me  some points : why Use EJB  over cdi ?

        • 1. Re: Why use EJB3 ?

          Could you elaborate on this? I did not get your question exactly.

          What you mean by advantage of EJB?


          If you use CDI it wil make your life easier and prevent from writing boiler plate code.

          • 2. Re: Why use EJB3 ?

            HI,  Wolf Dieter Fink

            We have a planing to build application using java ee . applicaiton is financial highly concurrent and transactional ,secure app (banking solution).

            I have some idea on EJB and also CDI . i am faceing some confusion about the usage of CDI and EJB. when to prefer one over the other.


              CDI = dependency injection

              EJB =  NOT DI


            i have one thousand user simulteneouly use this app. so, i have need Jboss applicaiton (WIldfly) clustering support.  It is sophisticated product ,

            so, long time we have maintin this application .


            for the following secanrio, which one is good for our future managability .

            • 3. Re: Why use EJB3 ?

              If you use a server environment I would use EJB.

              But with EJB3 you still have dependency injection, I suppose you will not start with an old EJB2 application, right?

              Also it is possible to use CDI beans as well.

              This depends on your use case and which front end you use.

              • 4. Re: Why use EJB3 ?

                Hi Wolf-Dieter Fink ,


                Ans 1 : yes , we have to use server environment (wildfly) .

                Ans 2 :  EJB 3.2

                Ans 3 : it is web application , front end may be - struts2/jsf2.


                i want to know that which use case for EJB is good

                and which use case for CDI technology perfect match for real life case study.



                Note :

                i have good theoretical knowledge (EJB and CDI) but  i can not make decision , which use case  cdi /ejb perfect.

                From my study .. i have found that

                   EJB model is perfect for  = When need clustering , highly concurrent / transaction , security , timer , asynchronous process,service integration , mission critical complex financial                                                 application , different application server pool.

                   CDI is perfect for  = maximum case cdi is same as EJB . recent slogan is CDI is perfect for any requirement of application . it fulfill all   mission critical complex requirements.

                                                recently, several consultant / forum /j2ee expert says that for all type of requirement CDI is enough , No need EJB .



                   for this reason, i can not select which one is perfect CDI/EJB . Because from internet , i have found ambiguous information about ejb/cdi. i develop a demo with two technology

                   (CDI 1.0/ EJB3.2) for wildfy , i have found same result . i think , technically cdi / ejb has some difference(scope) but usage  point of view , it has no difference .


                  Please give brief idea , from real life scenario.