Spring Vs. EJB 3.0

I really don’t want to give it a link, but you really need to read it yourself…then maybe come back to see what I thought of it.

ONJava.com: POJO Application Frameworks: Spring Vs. EJB 3.0

You can also read what I believe was the rough-draft at Michael’s blog…where he was even more blatantly anti-Spring.

Man…what a pile of shit. Before I dig down, I’ll tell you up front that I don’t know much about EJB 3.0 and I’m only a novice Spring user…but hey I’m pretty sure this guy has only a very cursory knowledge of Spring.

This is supposed to be a comparison piece between Spring and EJB 3.0. It isn’t. It is really more “Here’s why I heart EJB 3.0 (and Jboss) more than Spring”. Is this apples to apples? Does Spring functionality == EJB 3.0 functionality? I’ve never really heard EJB referred to as an “Application Framework”…maybe it is? Anyway, I don’t think they are mutually exclusive. So to clarify, he’s really comparing functionality specified in EJB 3.0 with how that functionality can be achieved with Spring.

His problems with Spring are: Spring is not a standard and Spring uses icky xml instead of sexy annotations. Pack it up guys…Spring is not a standard…there is no jcp process for it…what the hell were we thinking…sorry to bother you, we’ll be on our way now. What do you MEAN? Should Rod et al have waited until EJB3.0 spec was in the books before launching Spring. Or are you saying “thanks for all the help Spring…we [JBoss with our EJB3.0 shield] will take it from here”. I really love [please read the sarcasm there] how he makes it sound like the 2 were done at the same time…when in reality EJB 3.0 would not be what it is if it were not for Spring’s popularity. I think it is great that EJB3.0 will be more pojo-centric and that it will be cleaner and that it has taken some good things from Spring and Hibernate and will be vastly improved over 2.1. That doesn’t mean that Spring goes out the window. I think (again…I’m not totally familiar with EJB3.0) that they can complement each other.

Annotations are nice…Spring does support them…but apparenlty not as sexily as this guy seems to think it should. I personally think annotations can be over-used. Sure, let me specify transaction rules via annotations, but dependency resolution and security rules? I’d prefer to have that externalized because (in my opinion) it’s more flexible/pluggable that way (not as close to the code and doesn’t need a recompile to reconfigure). Granted the recompile argument is less an issue in an enterprise environment where you probably recompiled before any change gets pushed to production anyway, but I still believe the xml file to be more flexible from a configuration standpoint. Maybe the future will show I’m wrong and I’ll be all about annotations…but the bottom line is that the xml config file is really not complicated and I hope I never have to work with someone who has a hard time reading/understanding them.

I was going to do a more in-depth analysis…commenting on individual lines, but that would take to long…I may still do that later…but I must do at least one:

…in-container tests are recommended, as they are easier, more robust, and more accurate than the mock objects approach.

…right…no reason, no backup, just take it as fact statement of crap. I would have even been ok with: “Now that EJB is more pojo-centric and you can fireup a simply configured container within the test so it is easier/more feasible to run automated and in-container tests…”, but I doubt that is true.

What a missed opportunity. I really think this could have been a simple intro to EJB3.0…with maybe mentions of the simlarities/differences with Spring instead of the bash piece it clearly was.

One Response to “Spring Vs. EJB 3.0”

  1. Nate Minshew Says:

    I also liked his comment on having to refactor your daos if you switch between hibernate and jdbc. If he developed his applications using standard architectural patterns, then we wouldn’t have to refactor crap. The comment on the article hit it on the dot when the person said they didn’t have to refactor anything, just change a couple of lines in an xml config file.

    A good example is the JBoss MicroContainer, which is even more generic than Spring, as it handles Aspect-Oriented Programming (AOP) dependencies.

    Why would you want to handle AOP dependencies? I thought the whole point was to not have to have AOP dependencies in your code. Doesn’t that belong at a higher level.

    Also you can make much more concise transactions with correct usage of the proxy class and AOP that are not anywhere near as complex.

    Anyway, bottom line is I’ve seen a lot of good articles on Onjava.com, but his certainly is not one of them. I truely hope no one reads this and thinks too much of it.

Leave a Reply