I am a Java Developer working in Sydney. I am eager to learn new technologies, new frameworks, new languages. Thibault has posted 8 posts at DZone. You can read more from them at their website. View Full User Profile

Spring vs Java EE: What People Forget About Spring

07.16.2012
| 37158 views |
  • submit to reddit

Introduction

A few days ago, I was listening to episode 85 of the Java Spotlight Podcast. In this episode, Bert Ertman and Paul Bakker were talking about migrating from Spring to Java EE. Basically, in their introduction they were saying that, nowadays, there is no point choosing Spring over Java EE. We can read it in their article:

It took a while but Java EE has finally made the leap to be a standard, lightweight, fitting solution to the vast majority of real-world development challenges in the mainstream enterprise applications space. You should have no single reason beyond choosing the standard.


Over the last couple of months, I have seen a lot of blog articles with similar thoughts. Some are praying for Java EE, which is a good thing, while others are just denigrating Spring. This is the case of the article of Arun Gupta. My first thought on this article was "Oracle might be really desperate to write such trolls...". I am not at all a Spring evangelist, nor a Java EE hater. On the contrary, I have used intensively Java EE 5 for two years and am really happy to see it rise as a competitor to Spring. My goal is not to pray for Spring here, either, just to balance the words of the "Spring haters."

Standard- VS Single-vendor solution

Is it good to have standards?

Do you know the sentence "Responding to change instead of following a plan"? It is one the Agile rules. It is not only good to have standards, it is fundamental! But it comes with its drawbacks. If one day you have a problem with a standard because of something not covered by that standard, your only solution is to fill an issue, cross your fingers and wait three, or so, years.

Are Spring and standards incompatible? Not at all!

That is one of the reasons I do not understand the "It is standard" argument. Spring does its best to provide the use of the standard. You are free to use JPA, the CDI annotation, etc. I consider Spring more like an integration platform that lets you use all Java EE technologies and also some additional features provided by Spring itself.

Do I depend on SpringSource? Not really.

What happens if tomorrow SpringSource stops developing Spring? I know I will continue using it. Spring Framework is under the Apache 2.0 license, and the community will undoubtedly take the relay - companies will be sure to offer support for Spring users. Even if nobody does that, I am happy with Spring Framework in its current state. Why would I change? Maybe I will reconsider it in three years when a new version of Java EE is released ;) What happens if tomorrow I am not happy with Spring Framework? The same thing than if I am not happy with Java EE: I stop using it. If tomorrow I am not happy with my application server, the same thing will happen. I'll change it. Spring gives me more choices, though (since Spring works with all Java EE application servers and others, like Tomcat Jetty, etc.).

Spring has always been and will always be

I will never forget that Spring has made CDI possible and easy for Java web development. Java EE has followed (again three years later) with the JSR-299. Spring is also currently providing some awesome solutions that JavaEE is not:

  • Spring Data (Really nice especially for the NoSQL world)
  • Spring Social (Woops... JSR-357 has recently been rejected)
  • Spring Mobile

Some of them are in the plan of the next versions of Java EE (Yay! We will have it in three years!) while others have still been disregarded, or rejected altogether.

Integration Testing

One of the common arguments for Java is that you don't have to use mocks. You can do in-container testing thanks to Arquillian. I am definitely in favor of in-container testing instead of mocks, and Arquillian is a great tool. Arquillian is nice for Java EE but it is not Java EE! It has no standards and so you depend on a single vendor, JBoss (redhat), which makes the "It is standard" argument pointless. Then it is possible to test spring with Arquillian. At least, even if it is not perfect, Spring has the merit to provide something like that.

Conclusion

I have not focused my article on the enhancement provided by the Java EE platform, nor on the different features implemented by each. That wasn't my goal. I still believe that Java EE is a really good product and that it has finally become a serious competitor. But when I read "While Spring was revolutionary in its time [...], it really is last generation's framework - some people are even calling it legacy" that really annoyed me. How can someone say that?! Maybe it was just to create a buzz.
Published at DZone with permission of its author, Thibault Delor.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Sergio Samayoa replied on Thu, 2013/02/07 - 5:55pm

JEE 6 is FAR superior than Spring because:

  • Learned from 10+ years of mistakes.
  • Learned, adopted and enhanced concepts that Seam, Spring and others resolved in their scope and their time.
  • Standardization.
  • Supported by big players!

Spring, Seam and other frameworks resolved problems that no longer exists with JEE 6.

Juan Pablo Crossley replied on Mon, 2013/08/19 - 6:09pm

I work for a company that have a very known product been deployed in several different countries, the product has been around for 8 years, and I will say that we started with the idea of: "Stick with the standards because that will ensure us our product will run in all the servers that are compatible with the standard", what a bad decision we made, the standard is not standard at all and you're lucky if your solution run straighforward in all the servers, for example sometime ago we decided to use EJB3 and surprise, every single server we tried had some problem with something not implemented or not supported as other servers, I would say, stick with the standards if you're building a solution that will run only in one server, if you plan to deploy on several, you will have nightmares, as we do. One simple example: If you need to avoid caching of some entities, because other system uses the same table, you will need to put non-standard annotations (that'll tie your code to that vendor),

I really hope the JEE vendors understand the importance of what "standard" means, and been able to fulfill long promise of java "Write once, run anywhere", we usually joked about this with: "Write once, run anywhere... if you can".

The good thing about spring is that it runs exactly the same way on any server, even in servers that dont support the JEE 5+ standard.

Nice article,

Noel Padzinza replied on Thu, 2013/11/14 - 11:02am

I totally agree with you. Your argument is justified. Spring is solid and a serious competitor and deserves to be recognised as such. However JavaEE has grown over the years and its very stable as well. I guess at the end of the day its just a matter of preference. web design Melbourne.

Edward Villanueva replied on Sun, 2013/11/24 - 1:48pm

I am impressed by the content of this site. The ideas and thoughts  of the author are really good. Thank you for sharing it to others. 

Mithipati Kames... replied on Sun, 2014/06/22 - 11:07pm

I  had few questions after working with both spring and javEE to Reza Rahman sir, 

Why I need to use Big App servers with huge Heap requirements for  EE (like EJB3.2, Transactions, etc) not available in Java EE Web profilers (like tomcat or jetty) ? can't it be simple like Spring framework which can work with any server/standalone and can replace container based EE(like transactions, security) with any third party (may be better) ?

What EJB 3.1/3.2 stateless session beans good for? And, 

What they are doing so special that there is no parallel and simple technology or way of doing? 

Can't we achieve this with simple RMI (distributed apps) and web services ?

Is RMI over JRMP is not good for distributed applications we need to use RMI over IIOP (CORBA's protocol)?

Also what percent of enterprise apps having clients written different languages need to access java remote objects using EJBs (CORBA) even after having better technologies like JAX-RS and JAX-WS? 

As far as my understanding EJB 3.1 entity beans nothing but JPA with vendor based implementation if I'm not wrong ?

Eg. JBoss -> Hibernate, Websphere-> OpenJPA, Weblogic -> toplink etc.,

any way these can be implemented without the Big App server support. 

Coming to timers -> What EJB timers can achieve different from J2SE Executor Services (Scheduled thread pools and others) ?

I could not buy the idea of EJB 3.1/3.2 with full blown Application servers. Tell me something that I can't achieve/write a scalable secure enterprise application without EJB 3.1/3.2 with big baggage of Application server to carry, just because it is a standard?

Leave who copied/borrowed whose idea and their evolutions. Today with spring framework and annotations can't it be comparably as simpler as EJB 3.1/3.2 to develop Enterprise grade applications with out full blown Application servers?
Why do you think spring framework is so bad. Just because it is not part of any (especially JEE) standard?
I used EJB 2.1 Entity beans because there is no alternative technology like today Hibernate or Eclipse link etc., also there are no alternative containers like spring, guice etc., But today there are so many light weight containers available still do you suggest me to use EJB 3.1/3.2 ?
I  would like to know your impartial thoughts on these questions for better Java EE applications

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.