Spring 3.0 vs Java EE 6.0

SpringJakarta Ee

Spring Problem Overview


I'm confronted with a situation...

I've been asked to give an advise regarding which approach to take, in terms of Java EE development between Spring 3.0 and Java EE 6.0. I was, and still am, a promoter of Spring 2.5 over classic Java EE 5 development, specially with JBoss, I even migrated old apps to Spring and influenced the re-definition of the development policy here to include Spring specific APIs, and helped the development of a strategic plan to foster more lightweight solutions like Spring + Tomcat, instead of the heavier ones of JBoss, right now, we're using JBoss merely as a Web container, having what I call the "container inside the container paradox", that is, having Spring apps, with most of its APIs, running inside JBoss, So we're in the process of migrating to tomcat.

However, with the coming of Java EE 6.0 many features, that made Spring attractive at that time, easy deployment, less-coupling, even some sort of D.I, etc, seems to have been mimicked, in one way or the other. JSF 2.0, JPA 2.0, WebBeans, WebProfiles, etc.

So, the question goes...

From your point of view, how safe, and logical, it is to continue to invest in a non-standard Java EE development framework like Spring given the new perspectives offered by Java EE 6.0?

Can we talk about maybe 3 or 4 more years of Spring development, or do you recommend early adoption of Java EE 6.0 APIs and its practices?

I'll appreciate any insights with this.

Spring Solutions


Solution 1 - Spring

The crucial point IMHO is not the one of features. In that regard, Spring will always be ahead of JavaEE as it's natural for OpenSource VS. a Standard. So one fact is, that you get the new features much earlier with Spring that with JavaEE (e.g. container integration testing is a new feature in JavaEE 6 and has been available in Spring for ages).

The most important point IMHO is the one of lifecycles for administration and development. When you choose JavaEE, you tie your programming model to your infrastructure. Usually app server vendors are not the fastest adopting new standard's versions (blame WebSphere, JBoss, what have you). So this means we probably won't see production ready, JavaEE 6 supporting products by the big vendors before end of the year.

Even if that is the case then you still have to take the hurdle of your administration, IT department and budget controlling managers to be willing to upgrade to this shiny new version. Coming from this side, JavaEE 6 is not even an option to many shops. You can choose what ever you like to deploy your apps to? You wanna choose Glassfish for production? Go ahead, try. Most shops aren't in such a "comfortable" situation.

Exactly contrary: Spring. Decoupled programming model from infrastructure. Go take current 3.0.x and use @Inject, JPA 2 and the like in your Tomcat or legacy application server.

Solution 2 - Spring

If you're already a Spring shop, why bother switching? You're happy with it, it does what you want, it's actively developed, you're probably not looking to run outside of Tomcat any time soon, if ever, since Tomcat is very mature, and runs everywhere. So, any promise of portability that Java EE might suggest is right out the window.

I see no reason to switch away from Spring.

Solution 3 - Spring

Since Will and Oliver already said the most crucial stuff I'll only add that: "if it works and does the job done, then leave it alone!". "Newer" and "standardized" doesn't always equal "better", in fact it rarely does - new things are clunky and buggy and (that's the most important to me) not widely supported. If the rest of Java EE 6 is as "standardized" as JSF2.0 (and all the Rich/Ice/Prime/WhateverFaces), then believe me stick to Spring for now. A lot of companies stick to a bit older technologies for a reason (stability > *), Spring's been on the market for years and is well established.

@Edit: Especially for @ymajoros: JSF (both 1.x and 2.x) is a flawed standard due to multiple reasons and is useful only in a handful of cases (i.e. when you are creating small, simple CRUD websites or when you're a Java EE enthusiast):

  • creating new components is a pain in the ass. Since it is a component based framework I would assume it would make things easier not harder. Currently I prefer to go with a JS+Java on the backend approach since it is actually easier for me to create components there. The only saving point of JSF is that there's a ton of components libraries. Problem starts when they don't work, you want to change something or create your own component.
  • exception handling is a mess (or did something change in the past year or two?)
  • JSF has problems with being too stateful - few bad decisions, one bad dev in your project and half of your app can be stateful and serialized.
  • the UI part of the standard does not (or at least didn't when I wrote this answer) cover most collections from Java (in fact only decently covered data structure was a List).

As for the standard which you are so fond of: did they at last somehow integrate JSF with JAX-RS? Because last I checked those specifications were totally separated even though you could make a lot of improvements. For instance why can't I annotate a method with @Path in my backing bean so it would be both handled by a REST request and a JSF request?

Maybe some (all?) of those issues are now fixed but when I wrote this answer they were but few among all the bad things about JSF and the standard in general.

Currently if I want to create a very small, simple CRUD app I go with Play 2.0 (even though it is one huge anti-pattern) or something like RoR. When I want to create a large, "enterprise level" app then I grab a JS framework (like ExtJS) and a JS component library combine it with Java backend (and for instance Spring) and I do what I need without any overhead this so called standard would bring.

Of course there are cool parts of JEE6 like JPA2, JAX-RS2, bean validation isn't all that bad. But using the whole standard stack only because they called it a "standard" (and as I mentioned above most of the specs don't even synergize) is, in my very humble opinion, just wrong.

Solution 4 - Spring

I think you will have noticed working with Spring makes you more productive than Java EE. I don't think they will ever be able to make the pig (Java EE) really fly. Java is a great language/platform, don't cripple it with Java EE. Why settle for 'some sort of dependancy injection', if you can today have Spring?

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJose DiazView Question on Stackoverflow
Solution 1 - SpringOliver DrotbohmView Answer on Stackoverflow
Solution 2 - SpringWill HartungView Answer on Stackoverflow
Solution 3 - SpringMateusz DymczykView Answer on Stackoverflow
Solution 4 - SpringMaarten AbbringView Answer on Stackoverflow