File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes Spring and EJBs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring and EJBs" Watch "Spring and EJBs" New topic
Author

Spring and EJBs

Mark Garland
Ranch Hand

Joined: Nov 11, 2006
Posts: 226
Hi Craig,

I am studying towards SCBCD, learning for the first time all about EJBs and the new JPA architecture.

I've always seen Spring as something that was written to circumvent the deficiencies in EJB2.x, and now EJB3 has been released I would imagine that the need for Spring is lesser?
A colleague points out that Spring also manages the frontend/web aspect, which EJB3 doesn't (as it is for the business layer), however I would imagine that by using something light like struts, JSF or some other framework you could achieve the same things?
I'm sure I've also read somewhere that Spring is great for smaller projects but isn't as scalable as EJBs etc. which gives me concern over using it for large business systems.

My questions would be
- Where does Spring fit? Does it still have relevance? What can Spring do better than an EJB and Web framework combination?
- Is Spring as Enterprise level as EJBs, especially in terms of clustering and scalability?

Thanks,

MG


28/06/06 - SCJP - 69%, 05/06/07 - SCWCD - 92%, 28/02/08 - IBM DB2 v9 Fundamentals (Exam 730) - 87%, 18/11/08 - IBM DB2 v9 DBA (Exam 731) - 89%, 26/02/11 - SCBCD - 88%
Anil Vupputuri
Ranch Hand

Joined: Oct 31, 2000
Posts: 527
Mark Garland wrote:
- Where does Spring fit? Does it still have relevance? What can Spring do better than an EJB and Web framework combination?
- Is Spring as Enterprise level as EJBs, especially in terms of clustering and scalability?


Very good information and answers can be found at webpage


SCJP 1.5, SCEA, ICED (287,484,486)
Alaa Nassef
Ranch Hand

Joined: Jan 28, 2008
Posts: 460
Well, I think that this article is a little outdated (June 2005). Anyway, spring's main advantages are
  • Doesn't need a container
  • Integrates with lots of technologies easily
  • Simplifies a lot of APIs when integrating with other technologies (mail for example)

  • However, EJB 3.1 has a light version that doesn't need a container. Finally, Spring is great with Aspect Oriented Programming (AOP). Don't know if EJB has that.


    Visit my blog: http://jnassef.blogspot.com/
    Jeanne Boyarsky
    internet detective
    Marshal

    Joined: May 26, 2003
    Posts: 30537
        
    150

    Spring is still ahead of EJB. For example, Spring does dependency injection anywhere and of any interface. J2EE only allows it in session beans, MDBs and Servlets. And even then only certain types of resources. Similarly for AOP. EJB has interceptors; Spring has AOP anywhere.

    I think it is true that EJB has an advantage in scalability, but only in specific scenarios. If you are doing relying on your EJB layer to go to different servers to handle load and scalability, EJB is designed for this. However, most people don't use this feature and handle load balancing at the servlet or messaging layer instead.


    [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
    Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
    Mark Garland
    Ranch Hand

    Joined: Nov 11, 2006
    Posts: 226
    Hi Anil, Alaa and Jeanne,

    Thank you for your replies.

    The idea of being able to run without a container is certainly appealing as they can often be quite slow (especially if the machine has limited hardware).

    The idea of handling scalability at the messaging layer is a great idea that I hadn't really considered and I guess that this would easily circumvent the need for complex clustering on the side of the container. I guess though that this wouldn't work so well for SFSBs, however I am not sure how often these are actually used in practice due to their poor performance reputation from early containers; and I also suppose that if the interaction is web-based, the HTTPSession could be used here instead.

    A very interesting discussion - thank you for your inputs!

    MG
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Spring and EJBs