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
May 20th, 2005 at 1:03 pm
When will Spring have support for EJB3.0?
June 29th, 2005 at 9:30 am
sounds like a desperate defense
July 1st, 2005 at 3:23 am
Not at all: sounds like a well-thought technical explanation of the merits of a good technology.
July 8th, 2005 at 8:24 pm
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.
August 3rd, 2005 at 4:26 am
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.
November 2nd, 2005 at 10:21 am
“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
November 17th, 2005 at 10:14 am
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
January 18th, 2006 at 10:13 am
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
July 28th, 2006 at 5:16 am
where are SPRING_EJB3Persistence .JAR
September 6th, 2007 at 9:25 pm
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]
September 7th, 2007 at 10:41 pm
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]
September 22nd, 2007 at 9:59 am
This is the coolest La Cocina. notem6715
September 22nd, 2007 at 9:59 am
This is the coolest La Cocina. notem6715
September 22nd, 2007 at 9:59 am
This is the coolest La Cocina. notem6715
September 22nd, 2007 at 9:59 am
This is the coolest La Cocina. notem6715
September 22nd, 2007 at 9:59 am
This is the coolest La Cocina. notem6715
September 22nd, 2007 at 9:59 am
This is the coolest La Cocina. notem6715
September 22nd, 2007 at 9:59 am
This is the coolest La Cocina. notem6715
September 22nd, 2007 at 10:00 am
This is the coolest La Cocina. notem6715
September 22nd, 2007 at 10:00 am
This is the coolest La Cocina. notem6715
September 22nd, 2007 at 10:00 am
This is the coolest La Cocina. notem6715
September 22nd, 2007 at 10:00 am
This is the coolest La Cocina. notem6715
September 22nd, 2007 at 10:00 am
This is the coolest La Cocina. notem6715
September 22nd, 2007 at 10:00 am
This is the coolest La Cocina. notem6715
September 22nd, 2007 at 10:00 am
This is the coolest La Cocina. notem6715
September 22nd, 2007 at 10:00 am
This is the coolest La Cocina. notem6715
September 22nd, 2007 at 10:00 am
This is the coolest La Cocina. notem6715
September 22nd, 2007 at 10:00 am
This is the coolest La Cocina. notem6715
September 22nd, 2007 at 10:00 am
This is the coolest La Cocina. notem6715
September 22nd, 2007 at 10:00 am
This is the coolest La Cocina. notem6715
September 22nd, 2007 at 10:01 am
This is the coolest La Cocina. notem6715
September 22nd, 2007 at 10:01 am
This is the coolest La Cocina. notem6715
September 24th, 2007 at 8:55 am
Hope you come back soon!! notem6715
September 24th, 2007 at 8:55 am
Hope you come back soon!! notem6715
September 24th, 2007 at 8:55 am
Hope you come back soon!! notem6715
September 24th, 2007 at 8:55 am
Hope you come back soon!! notem6715
September 24th, 2007 at 8:55 am
Hope you come back soon!! notem6715
September 24th, 2007 at 8:55 am
Hope you come back soon!! notem6715
September 24th, 2007 at 8:55 am
Hope you come back soon!! notem6715
September 24th, 2007 at 8:55 am
Hope you come back soon!! notem6715
September 24th, 2007 at 8:55 am
Hope you come back soon!! notem6715
September 24th, 2007 at 8:56 am
Hope you come back soon!! notem6715
September 24th, 2007 at 8:56 am
Hope you come back soon!! notem6715
September 24th, 2007 at 8:56 am
Hope you come back soon!! notem6715
September 24th, 2007 at 8:56 am
Hope you come back soon!! notem6715
September 24th, 2007 at 8:56 am
Hope you come back soon!! notem6715
September 24th, 2007 at 8:56 am
Hope you come back soon!! notem6715
September 24th, 2007 at 8:56 am
Hope you come back soon!! notem6715
September 24th, 2007 at 8:56 am
Hope you come back soon!! notem6715
September 24th, 2007 at 8:56 am
Hope you come back soon!! notem6715
September 24th, 2007 at 8:56 am
Hope you come back soon!! notem6715
September 24th, 2007 at 8:56 am
Hope you come back soon!! notem6715
September 24th, 2007 at 8:56 am
Hope you come back soon!! notem6715
June 6th, 2008 at 9:53 am
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