14 Replies Latest reply on Sep 5, 2008 8:39 PM by Jason Long

    EJB vs. POJO

    S T Newbie

      Hi,


      I am new in the field of seam and J2EE application programming. So I am asking myself what is better to use: EJB or POJO.
      So what I can say is, that I do need transactions but I also might want to reuse my beans (POJOs) in some other modules which are not running on the JBoss Server. So what should I use?


      Thanks in advance...

        • 1. Re: EJB vs. POJO
          Guillaume Jeudy Master

          Will your other modules run in an EJB3 container ? Please give more details.

          • 2. Re: EJB vs. POJO
            Damian Harvey Apprentice

            At present you can only hot-deploy POJOs. So for rapid development I'd make them POJOs but design it for when you might change the 'reusable' Beans to EJBs.


            A nice pattern that I've used and heard others use, is to have your page backed by POJOs so you can quickly hot deploy, and to have your business logic in EJBs which are injected into the POJOs. The idea being that you unit-test the EJBs independently of the page so you shouldn't need to deploy them as often.


            Cheers,


            Damian.

            • 3. Re: EJB vs. POJO
              Jason Long Novice

              Not being able to hot deploy is a major issue for me.  My project currently has over 100 SLSB and over 100 SFSB.  I am happy with how things work, but the redeploy is killing my productivity. :(


              I am about to switch the whole thing around, but I am a little nervous to do so in a mission critical production application.  I guess I will try this incrementally.


              Please vote for My Link

              • 4. Re: EJB vs. POJO
                Joshua Jackson Master

                Damian Harvey wrote on Sep 04, 2008 18:46:


                At present you can only hot-deploy POJOs. So for rapid development I'd make them POJOs but design it for when you might change the 'reusable' Beans to EJBs.

                A nice pattern that I've used and heard others use, is to have your page backed by POJOs so you can quickly hot deploy, and to have your business logic in EJBs which are injected into the POJOs. The idea being that you unit-test the EJBs independently of the page so you shouldn't need to deploy them as often.

                Cheers,

                Damian.


                Click HELP for text formatting instructions. Then edit this text and check the preview.

                • 5. Re: EJB vs. POJO
                  Jason Long Novice

                  I meant please vote for EJBTHREE-1096

                  • 6. Re: EJB vs. POJO
                    Joshua Jackson Master

                    Damian Harvey wrote on Sep 04, 2008 18:46:

                    A nice pattern that I've used and heard others use, is to have your page backed by POJOs so you can quickly hot deploy, and to have your business logic in EJBs which are injected into the POJOs. The idea being that you unit-test the EJBs independently of the page so you shouldn't need to deploy them as often.


                    Sorry for my previous entry.


                    Damian this is a good tips. But how would I differentiate a business logic that should go to the EJBs? Wouldn't this make the code much verbose because you would have too many layers like Spring? Isn't the idea of Seam is to reduce layers? And that is why in the first place Seam are able to use EJB as the backing bean?


                    cheers

                    • 7. Re: EJB vs. POJO
                      S T Newbie

                      Guillaume Jeudy wrote on Sep 04, 2008 18:21:


                      Will your other modules run in an EJB3 container ? Please give more details.


                      Hi,


                      no they should not need an EJB container! The modules should also run from the command line using some of the business objects.


                      Bests,
                      Sushi

                      • 8. Re: EJB vs. POJO
                        Vladimir Kovalyuk Apprentice

                        Although hot deploy does not work for Session Beans, it is still possible to change method implementation without re-deploy the whole app in debug mode. And I'm mostly happy with that.

                        • 9. Re: EJB vs. POJO
                          Damian Harvey Apprentice

                          It's just one possible pattern among many. You don't have to use it and Seam certainly doesn't enforce anything on you. In some ways it makes your code less verbose and easier to read as your EJBs are devoid of annoying properties that are only used to handle rendering and transient values.


                          In regards to what is your business logic, well that's your call, but if you remove anything that is only there to make the page work then that's a good place to start.


                          Cheers,


                          Damian.

                          • 10. Re: EJB vs. POJO
                            Vladimir Kovalyuk Apprentice

                            I've read https://jira.jboss.org/jira/browse/EJBTHREE-1096 and I doubt about it  because I expect JBOSS 5 will implement OSGI and I will happy with module-based re-deploy. If your application is so sophisticated I believe you will benefit from modularization much more that from hot-redeploy.


                            IMHO it is the matter of personal approach how one design and implement services. Just want to know what are you especially doing which changes your session beans signatures regularly.
                            Personally I strive to not mix time spent on design and time spent on implementation. (There might be extra concerns between design of service interfaces and implementation in big project team resulted to the conclusion that team should change interfaces reasonably rare).


                            From the other hand the process of designing JSF UI is annoyingly boring. So Seam featured hot-redeployable POJOs came in handy and it is really the priority. I won't state, but it seems that Wicket might bring efficiency of OOD in UI design process and Seam support is great news. I'm going to give Seam-Wicket a try (because I'm done with JSF which makes me think all the time about JSF lifecycle and limits me makes me think about how to overcome dozens of shortcomings in  EL, Facelets, JSF and Richfaces instead of concentrating on priority tasks)

                            • 11. Re: EJB vs. POJO
                              Jaime Martin Apprentice

                              Sascha, If you have no experience using EJBs I advise you not to use them because quite a few applications may be accomplished with POJOs and they are easier. But, I warn you that there are some features that are only provided by EJBs.Hope you don´t need some of them!!
                              In my current project I have not need to use EJBs so I have solved all my issues with POJOs.


                              Jason, I´ve just voted for EJBTHREE-1096. Hope it to be done in future releases!

                              • 12. Re: EJB vs. POJO
                                Jason Long Novice

                                Very interesting.  I was not aware that I could change method internals on SLSB and SFSB in debug mode.  I thought that only worked for POJO.  I can't wait to try. :)


                                You are quite correct regarding modularization.  My app has grown in to 1 big fat ear with 1 war and 1 jar.  I have just started to try to repackage everything in a modular fashion for reusability.


                                Now that I can package facelets templates and other resources in jars this should become easier.


                                • 13. Re: EJB vs. POJO
                                  Joshua Jackson Master

                                  Vladimir Kovalyuk wrote on Sep 05, 2008 12:28:


                                  I've read https://jira.jboss.org/jira/browse/EJBTHREE-1096 and I doubt about it  because I expect JBOSS 5 will implement OSGI and I will happy with module-based re-deploy. If your application is so sophisticated I believe you will benefit from modularization much more that from hot-redeploy.



                                  Vladimir,


                                  I think modularization that OSGi offers does not solve the redeployment problem. How would the appserver know there's a change in the code with OSGi?

                                  • 14. Re: EJB vs. POJO
                                    Jason Long Novice

                                    I connected to my remote server in Eclipse and changed some log statements inside a method on a SLSB and it worked. 


                                    Thanks for clearing up my confusion.


                                    However, when I step through the code I keep getting and error window popping up stating:


                                    An internal error occurred during: "Label Job".
                                    java.lang.IllegalArgumentException



                                    Any ideas?