Spring 1.2 RC1 Release Don’t quite get Yahoo! 360
Mar 29

Spring, EJB 3, and the future

Lightweight Containers Add comments

I am often asked whether Spring will be a flash in the pan, and everyone will move to EJB 3. There are definitely a set of customers who want to do the standards thing… and I have already talked about a path for those folks.

Then I saw the following from Juergen, via Keith Donald, which shows the point of view of the Spring guys:

Spring and EJB3

On the surface it may seem that EJB 3.0 (in particular session beans) covers the same area as Spring’s Lightweight Container. However, when you look closer, you’ll notice some important differences with regards to the two, both in terms of focus and capabilities.

Dependency Injection

EJB3 provides dependency injection for JNDI objects. All referenced objects need to be managed by the application server in JNDI. This is only appropriate for coarse-grained facades, as there is no value in letting the application server manage every single internal object of your application. Essentially, EJB3’s dependency injection capabilities are targeted at making JNDI lookups more convenient, but do not go beyond that.

In contrast to the above, Spring is designed for managing fine-grained application objects in a local fashion, without making the application server aware of each and every object. You can link in objects from JNDI if you need to, but most of your application objects are not (nor should be) managed by the server. Furthermore, Spring supports prototypes, constructor injection, factory methods, simple property values, value placeholders (variable configuration properties sourceable from external locations), control over bean lifecycle (lazy-init, disposal, pooling), and bean autowiring.

The most important difference is that Spring can seamlessly manage application objects in any environment, while EJB3 just allows you to run them in an EJB container. In a test environment or standalone environment, the best you can do with EJB3 is instantiate the session beans yourself. With Spring, you’ll just select a different context implementation, typically sourced from the same XML bean definitions. This means you can reuse configuration metadata across environments with minimal hassel.

Other Capabilities

Beyond those basic IoC capabilities, Spring offers full support for proxy-based AOP with prebuilt and custom interceptors, while EJB3 offers its fixed set of interceptors (transaction, security). Furthermore, Spring’s declarative transactions are backed by various transaction strategies (DataSource/JDBC, Hibernate, JTA, JOTM), working outside of J2EE too. There’s also support for a wide variety of data access strategies (JDO, OJB, JDBC, all using a consistent programming model, while EJB3 just integrates a single strategy). If you haven’t guessed by now, Spring’s mantra is, “it’s all about choice”.

We’ve not even touched Spring’s web support yet, which range from basic web application context support to its own web MVC and web flow framework and prebuilt Struts/JSF integrations, all able to seamlessly reference middle tier beans. There’s also support for lightweight remoting with various strategies (Hessian, HTTP Invoker, Burlap, JAX-RPC, JMX) using a common service export facility, rather than the (unknown?) set of protocols that a particular EJB server implementation may offer.

Spring in an EJB3 Scenario

In many respects, Spring and EJB 3.0 complement each other more than they compete. Like it currently does for EJB 2.x, Spring will be able to link in EJB3 session beans seamlessly (local or remote), and will provide internal contexts for EJB3 session and message-driven bean implementations (holding a Spring bean factory within an EJB).

In such an EJB3 scenario, Spring manages the application objects in the web tier (no matter which web MVC framework is being used), accessing coarse-grainded EJB facades when necessary, and potentially also finer-grained objects behind those facades (for example, business logic strategies and DAOs, using JDBC, JDO, Hibernate, etc). Spring still acts as the glue for the entire application, just now with EJB3 session beans thrown into the mix.

Beyond EJB3 session beans, Spring will also support the new persistence API defined by JSR-220 (formerly known as EJB3 entity beans), as a further O/R mapping strategy, in addition to the current support for Hibernate, JDO, OJB, and iBATIS SQL Maps. Note: this will be completely
independent from the rest of EJB3–you could easily manage your entire middle tier with Spring, using a JSR-220 persistence implementation in standalone.

EJB3 in a Spring Scenario

I hope the above answers why it still adds value to use Spring in an EJB3 scenario. Of course, we can also turn the question around: What value is added by EJB3 session beans to a Spring scenario? (JSR-220 persistence is a different matter: It’s an alternative to Hibernate and JDO, not to Spring.)

In principle, Spring covers all capabilities of EJB3 session beans today, offering more flexible and more sophisticated management and deployment options. The main benefit with modelling components as EJBs is that you’re able to export remote services through your J2EE server (to support load balancing and failover).

For purely local needs, there appears no compelling reason to choose EJB3 session beans over Spring-managed POJOs, except for one specific
scenario: You might want to deploy some of your components in a separate class loader within an EAR, making them accessible to multiple web applications. In such a case, using local EJBs as facades makes sense, possibly with fine-grained networks of Spring-managed application objects behind them.

Juergen Hoeller, co-lead, The Spring Framework

54 Responses to “Spring, EJB 3, and the future”

  1. Amarish Says:

    When will Spring have support for EJB3.0?

  2. Anonymous Says:

    sounds like a desperate defense

  3. Davide Baroncelli Says:

    Not at all: sounds like a well-thought technical explanation of the merits of a good technology.

  4. tony cala Says:

    Comparing to EJB 3, Spring concept is much powerful, it doesn’t have to be used in J2EE env. As a developer, I would appreciate the choices Spring provides. But for career safety, EJB3 seems a must have in near future.

  5. choon whee Says:

    I fully agree with the article.

    If you’ve used spring at a proficient level, you’ll know how true it is.

    The whole spring framework have this wonderful
    synergy that fits everything together so magically.

    I managed to build my system security, access rights and menuing based on rights as a seperate aspect that is totally transparent.

    My application still run without any visible difference when the whole aspect is removed and it don’t take me a single line of code to do that.

    I’ve also never changed persistent strategy so easily in my life.

    EJB 3 may take flight in some of its capabilities, but Spring is just so much more.

  6. neal ravindran Says:

    “The main benefit with modelling components as EJBs is that you’re able to export remote services through your J2EE server (to support load balancing and failover).”

    We can do that too with Spring today(Nov 2005) by using one of those “exporter” beans.

    Correct me if I am wrong “High availability with Spring can be gotten by clustering tomcat instances.”

    To me there is NO reason EVER to use EJB3

  7. Jimi Says:

    Neal, do you have any link to some page with more information about these exporter beans?

    Because I’m about to take part of a project to start a new website, and I’m very interested in this Spring framework. But it is nececary that it has very good support for clustering and load balancing.
    And I can’t seem to find any information about clustering, load balancing or exporter beans when I used the search function on springframework.org.

    Regards
    /Jimi

  8. Cory Adams Says:

    Jimi,

    What type of clustering do you need?

    If you are trying to cluster HTTPSession state you can rely on Tomcat, JBoss, BEA WLS to do that for you.

    If you are trying to provide clustering in the business tier than you must have requirements that would not allow you to use just stateless calls? If that is the case than a facade layer using Statefull Session Beans calling Spring managed pojos is an option for you.

    If you are trying to use some type of load balancing scenario you could either rely on a hardware load balancer or in a very specialized case you may use your EJB vendor’s capability to do this.

    For example JBoss can provide load balancing from RMI clients to SLSBs. This is a case whereby you may have rolled your own socket servers that handle a specialized protocol that then communicate to an appserver tier in which case you could again wrap Spring managed POJOs with SLSBs that are being load balanced using JBoss.

    So do you really need clustering and how will it be used?

    Cheers,

    Cory

  9. Anonymous Says:

    where are SPRING_EJB3Persistence .JAR

  10. Gabriel Says:

    busta chick i love lyric rhyme [url=http://yanik02.za.pl]busta chick i love lyric rhyme[/url]
    dora cartoon pictures [url=http://yanik02.za.pl]dora cartoon pictures[/url]
    fourteens [url=http://yanik03.za.pl]fourteens[/url]
    accesories for a nissan titan [url=http://yanik03.za.pl]accesories for a nissan titan[/url]
    chick solosis [url=http://yanik03.za.pl]chick solosis[/url]
    pictures of rachael ray [url=http://yanik03.za.pl]pictures of rachael ray[/url]
    wifeposters [url=http://yanik02.za.pl]wifeposters[/url]
    pictures of pekingese [url=http://yanik03.za.pl]pictures of pekingese[/url]
    per pay ppc click promotion strategy marketing [url=http://yanik02.za.pl]per pay ppc click promotion strategy marketing[/url]
    cheerleaders philadelphia eagles [url=http://yanik02.za.pl]cheerleaders philadelphia eagles[/url]
    topics for informative speeches [url=http://yanik03.za.pl]topics for informative speeches[/url]
    pictures of yeasts [url=http://yanik03.za.pl]pictures of yeasts[/url]
    kentuky fried chicken menu [url=http://yanik03.za.pl]kentuky fried chicken menu[/url]
    chicken kiev [url=http://yanik03.za.pl]chicken kiev[/url]
    breathe anna nalick lyrics [url=http://yanik03.za.pl]breathe anna nalick lyrics[/url]
    samantha big tit [url=http://yanik02.za.pl]samantha big tit[/url]
    stanley tookie williams pictures [url=http://yanik02.za.pl]stanley tookie williams pictures[/url]
    crosse picture tattoo [url=http://yanik02.za.pl]crosse picture tattoo[/url]
    herrera lorena picture [url=http://yanik03.za.pl]herrera lorena picture[/url]
    clicker training dogs [url=http://yanik03.za.pl]clicker training dogs[/url]
    young erections [url=http://yanik03.za.pl]young erections[/url]
    teen pusy pics [url=http://yanik02.za.pl]teen pusy pics[/url]
    click2asia [url=http://yanik03.za.pl]click2asia[/url]
    baldeagle pictures [url=http://yanik02.za.pl]baldeagle pictures[/url]
    in kiebler picture stacy thong [url=http://yanik03.za.pl]in kiebler picture stacy thong[/url]
    argumentative essay topics [url=http://yanik02.za.pl]argumentative essay topics[/url]
    siberian husky picture [url=http://yanik03.za.pl]siberian husky picture[/url]
    tactical shotgun [url=http://yanik03.za.pl]tactical shotgun[/url]
    digest preteen [url=http://yanik03.za.pl]digest preteen[/url]
    boob unreal [url=http://yanik02.za.pl]boob unreal[/url]

  11. WaSuReRu Says:

    filmmaking workshop [url=http://freesexvidslists2.za.pl]filmmaking workshop[/url]
    free mp3 tamil song [url=http://freesexvidslists2.za.pl]free mp3 tamil song[/url]
    unreal tornament downloads [url=http://freesexvidslists2.za.pl]unreal tornament downloads[/url]
    dvd sofware download [url=http://freesexvidslists1.za.pl]dvd sofware download[/url]
    filmeporno [url=http://freesexvidslists2.za.pl]filmeporno[/url]
    free myspace template [url=http://freesexvidslists2.za.pl]free myspace template[/url]
    moviesarena.com [url=http://freesexvidslists1.za.pl]moviesarena.com[/url]
    download dvd decrypter [url=http://freesexvidslists2.za.pl]download dvd decrypter[/url]
    v3 drag racer download [url=http://freesexvidslists2.za.pl]v3 drag racer download[/url]
    oregon trail game download for free [url=http://freesexvidslists2.za.pl]oregon trail game download for free[/url]
    actress film malayalam [url=http://freesexvidslists1.za.pl]actress film malayalam[/url]
    graffiti alphabets for free [url=http://freesexvidslists1.za.pl]graffiti alphabets for free[/url]
    alzheimers association eldercarehelpresources.com [url=http://freesexvidslists1.za.pl]alzheimers association eldercarehelpresources.com[/url]
    erotica movie sapphic [url=http://freesexvidslists1.za.pl]erotica movie sapphic[/url]
    bleach downloads manga [url=http://freesexvidslists1.za.pl]bleach downloads manga[/url]
    free melissa midwest pics [url=http://freesexvidslists1.za.pl]free melissa midwest pics[/url]
    dota download map [url=http://freesexvidslists2.za.pl]dota download map[/url]
    free bejeweled download [url=http://freesexvidslists1.za.pl]free bejeweled download[/url]
    vermont principals association [url=http://freesexvidslists2.za.pl]vermont principals association[/url]
    latimes classifieds [url=http://freesexvidslists1.za.pl]latimes classifieds[/url]
    create free buisness cards [url=http://freesexvidslists1.za.pl]create free buisness cards[/url]
    harley davidson jewlery [url=http://freesexvidslists2.za.pl]harley davidson jewlery[/url]
    el paso county assessors [url=http://freesexvidslists1.za.pl]el paso county assessors[/url]
    movieclips [url=http://freesexvidslists1.za.pl]movieclips[/url]
    free redwork patterns [url=http://freesexvidslists2.za.pl]free redwork patterns[/url]
    dota allstars downloads [url=http://freesexvidslists2.za.pl]dota allstars downloads[/url]
    free dvd decoder plugins for windows media player [url=http://freesexvidslists2.za.pl]free dvd decoder plugins for windows media player[/url]
    webcamlive free [url=http://freesexvidslists1.za.pl]webcamlive free[/url]
    the last day of my life phil vassar [url=http://freesexvidslists1.za.pl]the last day of my life phil vassar[/url]
    bank briana clip free movie [url=http://freesexvidslists1.za.pl]bank briana clip free movie[/url]

  12. shelly Says:

    This is the coolest La Cocina. notem6715

  13. shelly Says:

    This is the coolest La Cocina. notem6715

  14. shelly Says:

    This is the coolest La Cocina. notem6715

  15. shelly Says:

    This is the coolest La Cocina. notem6715

  16. shelly Says:

    This is the coolest La Cocina. notem6715

  17. shelly Says:

    This is the coolest La Cocina. notem6715

  18. shelly Says:

    This is the coolest La Cocina. notem6715

  19. shelly Says:

    This is the coolest La Cocina. notem6715

  20. shelly Says:

    This is the coolest La Cocina. notem6715

  21. shelly Says:

    This is the coolest La Cocina. notem6715

  22. shelly Says:

    This is the coolest La Cocina. notem6715

  23. shelly Says:

    This is the coolest La Cocina. notem6715

  24. shelly Says:

    This is the coolest La Cocina. notem6715

  25. shelly Says:

    This is the coolest La Cocina. notem6715

  26. shelly Says:

    This is the coolest La Cocina. notem6715

  27. shelly Says:

    This is the coolest La Cocina. notem6715

  28. shelly Says:

    This is the coolest La Cocina. notem6715

  29. shelly Says:

    This is the coolest La Cocina. notem6715

  30. shelly Says:

    This is the coolest La Cocina. notem6715

  31. shelly Says:

    This is the coolest La Cocina. notem6715

  32. shelly Says:

    This is the coolest La Cocina. notem6715

  33. miriam Says:

    Hope you come back soon!! notem6715

  34. miriam Says:

    Hope you come back soon!! notem6715

  35. miriam Says:

    Hope you come back soon!! notem6715

  36. miriam Says:

    Hope you come back soon!! notem6715

  37. miriam Says:

    Hope you come back soon!! notem6715

  38. miriam Says:

    Hope you come back soon!! notem6715

  39. miriam Says:

    Hope you come back soon!! notem6715

  40. miriam Says:

    Hope you come back soon!! notem6715

  41. miriam Says:

    Hope you come back soon!! notem6715

  42. miriam Says:

    Hope you come back soon!! notem6715

  43. miriam Says:

    Hope you come back soon!! notem6715

  44. miriam Says:

    Hope you come back soon!! notem6715

  45. miriam Says:

    Hope you come back soon!! notem6715

  46. miriam Says:

    Hope you come back soon!! notem6715

  47. miriam Says:

    Hope you come back soon!! notem6715

  48. miriam Says:

    Hope you come back soon!! notem6715

  49. miriam Says:

    Hope you come back soon!! notem6715

  50. miriam Says:

    Hope you come back soon!! notem6715

  51. miriam Says:

    Hope you come back soon!! notem6715

  52. miriam Says:

    Hope you come back soon!! notem6715

  53. miriam Says:

    Hope you come back soon!! notem6715

  54. Sachin Mali Says:

    This is a wonderful artical, I totally agree with author. Spring has many more features and is much powerful than EJB3.0. Spring offers many features across all levels of your application.
    Yes, EJB 3.0 simplified its declarative Transaction and Security feature, complexity.

    Thanks and Regards
    Sachin Mali

Leave a Reply

Spam is a pain, I am sorry to have to do this to you, but can you answer the question below?

Q: What is the number before 3? (just put in the digit)