5 Replies Latest reply on May 14, 2006 8:20 AM by mazz

    Combining EJB3 with MVC frameworks

    sateh

      i'm confused :-)

      I'm looking at EJB3 for the next application i'm doing and it all looks really great. Much more simpler than EJB 2.1. I can see myself building a good foundation for my app in no time.

      However, what do I do in the web layer? The Sun Java EE 5 tutorial only talks about servlets being able to have @EJB annotations. But servlets are retro. I want to use one of the more popular frameworks.

      What about WebWork, Spring MVC or Stripes to name a few. Do these frameworks automatically integrate with EJB3 or do they all have to make extensions of their own to make for example @EJB annotations work?

      S.

        • 1. Re: Combining EJB3 with MVC frameworks

          Use JBoss Seam it rocks!!!!!!!!!!!!

          • 2. Re: Combining EJB3 with MVC frameworks
            sateh

             

            "supernovasoftware.com" wrote:
            Use JBoss Seam it rocks!!!!!!!!!!!!


            It looks very interesting indeed. But, I don't want to make my current project more complicated than necessary. For Seam I would have to learn a new technology and for now that is not realy an option.

            S.


            • 3. Re: Combining EJB3 with MVC frameworks

              I admit that the initial learning curve is a little steep, but when you see how easy complicated things become you will never look back.

              You will get JSF plus a fantastic framework to connect it to EJB3.

              • 4. Re: Combining EJB3 with MVC frameworks
                sateh

                 

                "supernovasoftware.com" wrote:
                I admit that the initial learning curve is a little steep, but when you see how easy complicated things become you will never look back.

                You will get JSF plus a fantastic framework to connect it to EJB3.


                I'm more interested in the original question for now :-)

                If web frameworks will have to adapt to EJB3 then it will take some time before EJB3 is going to be really useful. The only option right now seems to be Seam or plain JSF I think.

                I know I can do most things with simple JNDI lookups like in the 'old days', but the annotations are what really makes EJB3 shine imo.

                S.


                • 5. Re: Combining EJB3 with MVC frameworks
                  mazz

                  As Gavin King likes to ask:

                  "What is the difference between:

                  @EJB MyEntity e;

                  and

                  MyEntity e = (MyEntity) initialContext.lookup(MyEntity.class.getName);

                  or, if you don't like to cast, write a utility to lookup:

                  MyEntity e = MyJNDILookupUtil.getMyEntityViaJNDI();"

                  Annotations to inject your EJB references is really not the strongest EJB3 feature - there is really no difference between wanting to use @EJB to inject your bean or wanting to use JNDI lookups.

                  POJO persistence is by far the biggest gain you get when go EJB3. And you can use your entity POJOs inside any client and work with them like any POJO - web frameworks, standalone Java clients, or whatever.

                  Look past the issue of using JNDI lookups and continue evaluating EJB3 - you'll find it extremely useful nonetheless.