Blogs

SpringSource Blog

A Response to: EJB 3 and Spring Comparative Analysis

Mark Fisher

Last night I attended a New England Java User Group (NEJUG) meeting where Reza Rahman presented a "comparative analysis" of EJB 3 and Spring. Reza is one of the authors of EJB 3 in Action. I enjoyed meeting Reza and respect him for presenting what may be considered a controversial topic. Also I appreciate that he did attempt to address pros and cons for both EJB 3 and Spring. Nevertheless, I feel compelled to clarify a few points that were not wholly accurate in his coverage of Spring and which led me (and other attendees) to believe the presentation was motivated by a bias toward EJB 3. To be fair, unlike a fixed specification version, Spring is constantly evolving and some of the things that I will point out here are new features. On the other hand, some are Spring 2.0 features that have been available for more than a year. I personally believe that a "comparative analysis" must account for the up-to-date feature set of the latest stable version of the products being compared. I think it goes without saying that I might be a bit biased as well, but my motivation here is to provide a wholly objective response so that the presentation could perhaps be revised to reflect a more 'apples-to-apples' comparison. I will provide brief responses to 10 "themes" of the presentation.

1. EJB uses annotations for metadata. Spring uses XML.

It was mentioned that Spring is beginning to support more annotations but that it is "going to take them a while". However, the Spring 2.0 release provided full JPA integration with @PersistenceContext for injecting the EntityManager and annotation-driven transaction management with Spring's @Transactional annotation (supporting the same semantics as a @Stateless EJB with the default propagation of REQUIRED). I was particularly discouraged that the comparison did not include JPA on both sides (see point #3 below). Spring 2.0 also introduced full annotation-based AspectJ support (@Aspect, @Before, @After, @Around) and the concept of "stereotype" annotations. For example, the @Repository annotation enables non-invasive Exception translation for data-access code that uses JPA or Hibernate APIs directly (without Spring's templates). Spring even provided annotation support as early as version 1.2, such as @ManagedResource for transparently exporting any Spring-managed object as a JMX MBean.

Now the main reason this issue is #1 for me, is the comment that it is "going to take them a while". As one of the main developers of Spring 2.5's annotation-driven configuration support, I must say that the Spring metadata model is extremely flexible and therefore we have been able to provide a comprehensive annotation-based model more quickly than one might expect. In fact, Spring 2.5 provides support for JSR-250 annotations: @Resource, @PostConstruct, and @PreDestroy – as well as @WebServiceRef and @EJB. Of particular interest is @Resource since it is the primary annotation used for dependency injection in EJB 3. With Spring, the @Resource annotation supports not only JNDI lookups (as with EJB 3) but also injection of any Spring-managed object. This effectively combines the main Spring advantage that was mentioned in this presentation (Spring supports DI of any type of object) with the main EJB 3 advantage (use of annotations instead of XML). Spring 2.5 also introduces an even more fine-grained annotation-driven dependency injection model based on @Autowired and the (extensible) @Qualifier annotation. Spring 2.5 also extends the "stereotype" annotations to include @Service and @Controller. Each of the stereotype annotations extends the generic @Component annotation by applying it as a meta-annotation. By applying the same technique, the @Component annotation provides an extension point for user-defined stereotypes. Spring can even auto-detect these annotated components as an alternative to XML configuration. For example, this excerpt is taken from the 2.5 version of the PetClinic sample application:

   <context:component-scan base-package="org.springframework.samples.petclinic.web" />

No additional XML is required for the web controllers since they use annotation-driven dependency injection and annotations for request mapping. I point this out, because the presentation specifically emphasized the verbosity of configuration for the web-tier:

@Controller
public class ClinicController {

   private final Clinic clinic;

   @Autowired
   public ClinicController(Clinic clinic) {
      this.clinic = clinic;
   }
   ...

For up-to-date coverage of Spring's annotation support, see: Introduction to Spring 2.5 on The Server Side, or the latest version of Spring's reference manual – specifically the Annotation-based configuration section. Also, stay tuned to this blog and the Spring Framework home for some soon-to-be-released articles and blogs covering version 2.5.

2. Spring allows you to support multiple deployment environments but requires more configuration.

This one was actually presented as a Spring advantage but with an emphasis on the configuration overhead. The truth is any project where testing and agile development are taken seriously is going to require supporting "multiple deployment environments". In other words, this particular topic often gets distorted as if it applies only to multiple production environments. In reality, having to deploy to an Application Server during each development and testing cycle is a major obstacle to agility. Typically Spring users will modularize their configuration such that "infrastructure" configuration (e.g. DataSource, TransactionManager, JMS ConnectionFactory) is separate and dynamic properties are externalized. Since Spring provides support for replacing '${placeholders}' based on the externalized properties, the inclusion of different properties files typically becomes a transparent concern.

3. EJB with JPA, Spring with Hibernate

I must admit this one bothered me the most. In the comparison slides, the EJB 3 examples showed JPA with data-access via entityManager and the entityManager instance being provided with the @PersistenceContext annotation. On the other hand, the Spring examples used Hibernate and showed setter injection of the Hibernate SessionFactory. In my mind, this violates the first rule of a bona-fide "comparative analysis": use the most similar feature available on both sides of the comparison. In this particular case, Spring does provide support for using the JPA API directly (i.e. JpaTemplate is completely optional; direct usage of the 'entityManager' still participates in Spring transactions, etc), and Spring also recognizes the @PersistenceContext annotation. This support has been available since Spring 2.0 (final release was more than a year ago), so I don't understand why the comparison does not use JPA on the Spring side as well. Other parts of the comparison were clearly based on Spring 2.0, so this leaves the impression of being selectively out-of-date and revealing a bias. If this particular example were modified to be 'apples-to-apples', it would have undermined one of the main overall themes: that Spring requires more configuration whereas EJB 3 relies on standard annotations.

Now, even though I believe the usage of Hibernate rather than JPA on the Spring side distorted the comparison, it does simultaneously reveal a strength of Spring. If you do want to use the Hibernate API directly instead of relying on the JPA API, Spring enables that, and it does so in a consistent way with regard to Spring transaction management and Exception translation. This then opens up the opportunity to use Hibernate features that extend beyond the limitations of JPA, such as Hibernate's "criteria" query API. By the same token, if you would like to add some direct JDBC for data-access where ORM is overkill, that is also supported in Spring – even when invoked within the same transaction as Hibernate or JPA data-access.

4. Spring makes no assumptions, you have to provide configuration.

One specific example was the definition of a transaction manager. It was stated that you have to understand things at the container-vendor level to configure Spring integration. This is incorrect. For example, the following bean definition does not contain any container-specific information, yet Spring will auto-detect the transaction manager in all Java EE Application Servers:

   <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>

If you do want to leverage container-specific features such as per-transaction isolation levels, then Spring also provides a few specialized implementations: WebLogicJtaTransactionManager WebSphereUowTransactionManager, and OC4JJtaTransactionManager. Switching between these implementations is only a matter of changing this single definition.

In addition to this, the Spring configuration slides were unnecessarily verbose. I'm afraid this may also have been motivated by the goal of emphasizing that EJB unlike Spring relies on intelligent defaulting. For example, the slide showed:

   <tx:annotation-driven transaction-manager="transactionManager"/>

Actually, if there is a single 'transactionManager' defined within a Spring context, then that attribute does not need to be provided explicitly on the 'annotation-driven' element. That attribute is available solely for enabling the usage of multiple transaction managers within one application if necessary. These techniques of "auto-detection" and "intelligent defaulting" apply throughout Spring, such as the JMS 'connectionFactory' for a message-listener (which is implicit in the example of #6 below) and the automatic location of an existing MBean server or RMI registry.

On a positive note, it was actually mentioned as an advantage that Spring allows for "local" transaction management. While EJB requires JTA for transaction management, many applications do not need distributed transactions across two-phase commit capable resources. In such cases, Spring allows for simpler transaction managers with less-overhead: DataSourceTransactionManager (for JDBC), HibernateTransactionManager, or JpaTransactionManager. I would have expected to hear a bit more detail on that particular Spring strength if the goal was to accurately describe the pros and cons. For example, this is a huge benefit for testing outside of the container or developing within a lightweight IDE environment such as Eclipse or IDEA.

Furthermore, if you do require JTA for distributed transactions but want to run in a lightweight container like Tomcat or Jetty, Spring easily supports standalone JTA providers like Atomikos and JOTM. Sure Spring's transaction manager setup requires configuration of a single bean definition, but it really is a one-time cost – and well worth the benefit.

5. Spring does not have a stateful application paradigm.

The benefits of a stateless service layer are fairly well-established as a best practice, and Spring embraces that. Spring does provide scopes other than singleton however. Spring's "prototype" scope enables a distinct instance for each injection or lookup, and Spring 2.0 introduced web scopes: "request" and "session". The scoping mechanism itself is even extensible; it's possible to define and map a custom scope to the notion of a conversation. Spring also supports simple object pooling with the CommonsPoolTargetSource, but object pooling is rarely the best solution for state management.

More importantly, Spring does provide very robust, highly configurable state-management for web applications via Spring Web Flow. There the conversational state is managed transparently, contrary to the claim of this presentation that developers have to interact directly with the HTTP Session to manage state in Spring applications. Furthermore, the repository configuration is pluggable so that various strategies may be used for physical storage of the state (session, client, backend cache, etc.). Finally, the latest developments in Spring Web Flow include support for extended persistence context and fully integrated support for JSF.

6. Spring requires configuration of a container per MessageListener.

Spring 2.5 provides a new 'jms' namespace to greatly simplify the configuration of message-listeners. Notice that there is no separate configuration for a container per-listener. Multiple listeners share the configuration, and intelligent defaulting is used extensively:

<jms:listener-container>
	<jms:listener destination="queue.confirm" ref="logger" method="log"/>
	<jms:listener destination="queue.order" ref="tradeService" method="placeOrder"/>
</jms:listener-container>

It was also mentioned that thread management is always a per-container issue. However, this is not true. The message listener containers actually use Spring's TaskExecutor abstraction, and there are a number of implementations available. For example, if running on Java 5+, you can configure a thread-pool executor, or you can even configure a CommonJ WorkManager executor. The executors can easily be shared across multiple listener containers if desired. In fact, the 'task-executor' attribute is available on the 'listener-container' element (shown above) where it would be logically set 1 time but shared by each container instance that is created internally per listener definition.

7. Concurrent Consumers cannot be greater than 1.

Okay, this was truly the most bizarre moment of the night. The code slide depicted a perfectly stateless implementation of a MessageListener (as it should be!), and then the configuration slide showed the 'maxConcurrentConsumers' value set to 1. At this point, it was stated that setting the value to anything other than one would cause thread-safety issues. I'm sorry to say, but this is flat out misinformation. The concurrent consumers setting determines the number of threads that are available for receiving Messages, and the 'maxConcurrentConsumers' determines to what extent the consumer pool can grow under heavy load (as demand decreases, the number of consumers drops back to the value set as 'concurrentConsumers'). As long as the MessageListener itself is thread-safe, this value can be increased to control throughput. Personally I would never use a MessageListener for anything other than delegating to a "service" so that even in the (very unlikely) case that I wanted to have a stateful object ultimately handling the content of the Message, then that target object would be configured with a pooling target source. The MessageListener itself would always be thread-safe and therefore the values for 'concurrentConsumers' and 'maxConcurrentConsumers' can be used as intended for managing throughput.

This topic raises one other point. A comprehensive comparison would reveal another pro of Spring here – namely Spring's listener adapter. The adapter provides automatic conversion from the JMS Message to a simple Java payload and then delegates to any Spring-managed object to handle that payload. For example, in the configuration above, the "logger" and "tradeService" listeners do not even have to implement the MessageListener interface. If they do not, then Spring automatically wraps those POJOs with an adapter that converts the Message and determines which method to invoke. It even converts a return value (if there is one) into a JMS reply Message and automatically replies to the destination specified by the incoming Message's 'reply-to' property. This same behavior is extremely difficult to implement from scratch since the JMS MessageListener handling method has a 'void' return type:

public interface MessageListener {
   void onMessage(Message message);
}

8. Spring's usage of the AspectJ expression language is powerful but cryptic.

EJB 3 is limited to @AroundInvoke, and the example showed this with some simple auditing applied through interception. The Spring example showed @Before advice since the auditing only required something to happen before the method execution (not around). I appreciated that the example emphasized the need to call context.proceed() on the EJB 3 side while the AspectJ @Before advice is much simpler. I was disappointed however that some of the attendees seemed to think that the AspectJ model was limited to @Before and therefore that EJB 3 @AroundInvoke was more powerful. To be comprehensive here, I would have included an example of @Around advice on the Spring side – to clarify that it is supported, but it is simply not always necessary.

The greatest limitation of the EJB 3 interception model is that the method (or class) that should be intercepted is directly annotated, whereas one of the fundamental goals of AOP is to be non-invasive – ultimately even supporting advice on code that is outside of your control. Given that goal, the AspectJ expression language is arguably as clear and concise as it can be while supporting all of the possible constructs where advice may be applied. While it may appear cryptic at first, it is fairly easy to learn. For example, it is conceptually similar but much more limited in scope than regular expressions (see the AspectJ homepage for the expression language reference for details).

9. Spring tool support has been sparse.

On this particular point, I would first point out that using Spring helps to reduce the development/test cycle so that a majority of a developer's time is spent within the IDE not deploying to an Application Server, and IDEs are great tools. The Eclipse-based Spring IDE is an incredibly valuable add-on for development assistance in Spring projects, and IntelliJ also provides Spring support in IDEA. As far as deployment tools, Spring-based applications can of course be deployed into any container, and since Spring can utilize the underlying resources (DataSource, TransactionManager, JMS ConnectionFactory, etc), these are managed in the same way as with any application deployed within the particular container. Spring's ability to expose any object as a JMX MBean (including support for the aforementioned @ManagedResource) and its support for JMX notifications/listeners is very powerful for custom monitoring and management requirements.

That said, clearly Spring could benefit from increased tool support. This is why the 'Spring Tool Suite' was just recently established to bring together Spring IDE, AJDT, AspectJ, and Mylyn and evolve into much more. For more information, see the articles and links available here.

10. With EJB as a standard, you can migrate from one vendor to another. With Spring, you still have to port the metadata.

Everyone knows that portability is "easier said than done". While EJB 3 may be less painful than EJB 2 in this regard (less verbosity in the configuration), the fact remains that Application Servers offer different features and thus different configuration options. Clearly if you are deploying to an Application Server, you probably should take advantage of certain specific features. The problem with the original statement is that it implies something at the level of application configuration that makes Spring inherently less portable. On the contrary, any Spring user who has migrated from one Application Server to another would agree that Spring provides a significant amount of abstraction in this regard. In point #4 above, I mentioned that Spring's JtaTransactionManager uses auto-detection within any Java EE Application Server and that the same applies for MBean servers, and RMI registries. Along these same lines, when using JPA, Spring detects persistence.xml and creates the EntityManagerFactory accordingly. In all of these cases, Spring metadata – whether it be annotations (@PersistenceContext, @Transactional, @Resource, etc) or XML ('jee:jndi-lookup', etc) is just as portable as any EJB 3 application.

Even when moving beyond the capabilities of a typical EJB 3 application, minimal configuration changes provide significant convenience. In this regard, Spring actually facilitates portability to a much wider variety of environments: Tomcat, Jetty, standalone, Eclipse, IDEA, and so on. My suggestion here would be to grab the Spring distribution's PetClinic sample application and try building and deploying the WAR file into multiple Application Servers. Then, notice that it can just as easily be deployed within Tomcat, and that the degree of portability actually far exceeds that of an EJB 3 application as soon as you want to switch between the different data access strategies that are supported by the application: JDBC, Hibernate and JPA. Take a close look at the different configuration files for those different versions (located within the 'samples/petclinic/war/WEB-INF' directory). Especially with the additions of Spring 2.5, the configuration is extremely concise. Notice that the only change necessary to switch between these different versions is one line in the web.xml where the Spring context is bootstrapped. If you want to run with a container-managed DataSource, use the one line 'jee:jndi-lookup' element. Otherwise there is a bean definition for using a standalone DataSource, and the actual database properties are externalized into jdbc.properties.

Conclusion

Well, it looks as though I had more to say than I thought :) . My intention has been to provide some objective clarifications from the Spring perspective, and I hope that is evident to the reader. I know that this presentation has been very popular at JUGs and conferences, and I think it's an important discussion. Many Java developers are overwhelmed by the vast number of options today, and it's important that they have all of the facts necessary to make well-informed decisions. While I have not emphasized it here (and you probably don't want me to go on any further), one point of the presentation as well as the book (EJB 3 in Action) is that Spring and EJB 3 need not be mutually exclusive. Spring can be used within EJB applications, EJBs can be accessed from Spring applications, and Spring now supports most of the same annotations: @Resource, @PersistenceContext, @PostConstruct, @PreDestroy, @EJB, and @WebServiceRef.

Similar Posts

Share this Post
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • DZone
  • LinkedIn
  • Slashdot
  • Technorati
  • Twitter
 

22 responses


  1. Besides Mark arguments, I'd like to point out project Pitchfork (http://interface21.com/pitchfork/) implemented "JSR-250 dependency injection, annotation processing and EJB 3.0-style interception" on top of Spring 2.0 and was used internally by WebLogic Server Tech Preview.

    It's a nice demonstration of how powerful and flexible Spring actually is. And with Spring 2.5, things got even better.


  2. I was at this NEJUG mtg and I had a serious reaction to the comments being made by the speaker. I saw Mark taking notes for this excellent rebuttal. Thanks Mark.

    I had to remind the group of the sad history EJB2 when choosing EJB3. And how Spring provided proven solutions before they were widely adopted. Unlike, many standards.

    The speaker made a statement that EJB3 was closer to the "convention over configuration" idiom used in Rails. But, he didn't seem to be aware of how Appfuse, which is based on Spring and provides the glue for multiple frameworks, leverages a set of conventions.

    When I'm working in J2EE/Java, although mostly Rails dev lately, I'll stick with Spring.


  3. As someone who has ported applications between various app servers (Tomcat, Oracle, Sun, JBoss) multiple times, I find the notion that EJB of any version is more portable than Spring. One of the big things that made our lives much easier than they would have been in the EJB world was Spring Security (ACEGI). Try porting an application written to the spec with even semi-complicated security configurations. It's not so fun. But with Spring it was pretty much a no brainer.


  4. Mark:

    Thanks a lot for commenting on my talk, I think it's helpful and constructive. I am going to post this as a cross-link on my own blog, I think it is a good supplement to get a response from someone on the Interface21 team. I honestly think a close examination of the slides (which you have graciously linked to), your comments, the good judgment of folks out there and a little bit of individual research/critical thinking is fantastic material for choosing between these great technologies or using them together. Too bad the talk wasn't recorded, that would have been great too. Oh well…maybe next time…

    I am a little disappointed (mostly at myself) that your reaction to the talk is more negative than positive. Hopefully I wasn't too negative on my coverage of Spring during the talk! I've always had a high opinion of Spring and think it is an overall positive influence on Java (both to Java the tool and Java the standard).

    I'll make just two comments that might not be self-evident to folks otherwise:

    1. As you correctly noted, this sort of analysis is always a moving target. I am definitely going to update the analysis once you guys move to a production release of Spring 2.5. As I mentioned, it's great to see you guys are supporting more annotations and even some annotations in Java EE. I hope to one day see a 100% compatibility between EJB 3.x and Spring (hopefully without any additional configuration to bootstrap Java EE features). I think that will be greatly beneficial for the developer community. Talk about the best of both worlds!
    2. As I mentioned in the talk, using Hibernate for Spring is just a little bit laziness in cutting and pasting from an existing project :) . There is no malice intended. I will definitely update the presentation with configuration to use JPA in Spring outside a container. It isn't too difficult for a developer to make this change themselves by looking at the Spring documentation for JPA. I'm not sure how much of a difference in the overall analysis it will actually make, though.

    All in all, great to have chatted with you and hope we'll cross paths again. I'm encouraged that you see the value in the comparison and pointed out that EJB and Spring are not mutually exclusive technologies (I was hoping that would shine through as a central aspect of the talk too). After all, what's a little bit of controversy? The fact that Java can stir up so much passion is one of the best indications that Java is as healthy as ever!

    All the best,
    Reza

    PS: Definitively keep me posted if you think of anything else. It's a tricky topic, I'd like to make sure I'm being as fair as possible.


  5. I just got a brainstorm!

    Would you mind if I used your post as a "brain teaser" for EJB 3 in Action readers and attendees to my talks? As I mentioned, it could be used as an excellent tool for digging a little deeper into Spring/EJB3 and thinking through the issues/formulating independent opinions…promise I won't modify anything, just a straight screen scrape…

    This reminds me of a pretty memorable exercise I did way back in school (Philosophy 104, I think). Essentially presenting two "incomplete" sides of an issue and asking players to "fill in the gaps" with independent critical thinking, sometimes offering "breadcrumbs" or "clues". I think this sort of thing could jive great for engineers and add some color to an otherwise pretty dry presentation…

    Thanks in advance,
    Reza


  6. Hello Mark, Reza,

    "Spring actually facilitates portability to a much wider variety of environments: Tomcat, Jetty, standalone, Eclipse, IDEA, and so on."

    I've been able to port to these with EJB 3, so technically that's not correct. Of course it depends on the container being used and yes there will always be porting issues between vendor implementations regardless if using EJB 3 or Spring.

    And to be fair, the EJB 3 and related standards are also evolving as well so we could go on with these feature by feature nitpickings for some time. I could counter more of the points raised above but that isn't what we should be doing.

    Spring's raison d'être was J2EE (EJB 2.x). Now that EJB 3 addresses many of the issues Spring provided solutions for we should focus on standardization. The fact the Spring 2.5 now supports similar annotations, and that we have Pitchfork, indicates a positive direction towards a standardization goal for Java enterprise application development.

    It's not really productive to have a 'comparative analysis' that pits these two against each other. We should agree to embrace the JCP standards, namely the EJB 3, JPA and additional specifications and move on from there.

    If that means Spring's importance as an alternative to the JEE standards is diminished, so be it. I'm not knocking Spring, as it's more than just a framework now and there's a large community out there but Spring can be used alongside or as part of a JEE 5 application server solution – so we should focus on promoting interoperability.

    My point being that Spring can be viewed to exist under the JEE/EJB 3 standards umbrella providing enhancements much like JEE server vendors do. We shouldn't have to force developers to take sides here. Some developers may not take to Spring's style and some will embrace it, but let them communicate via the JCP based EJB 3 standards.

    -Dario


  7. Dario:

    I definitely hope for a burying of the hatchet and collaboration between Spring and EJB 3.x to advance a common cause (Java EE). A comparison is obviously pretty moot if Spring becomes an EJB 3.x container.

    I do agree with Mark that a lot of people are searching for answers for choosing between the two right now (I know of three such comparisons so far, all with similar results). I don't think a comparison should be cause for needless heartache, though. Rather, all comparisons done in good faith is an opportunity to learn something pretty neat (and I can honestly say I’ve done mine in good faith and have not been stingy in pointing out the many strengths of Spring). I recall countless comparisons for products ranging from presentation tier frameworks and scripting engines to IDEs and build environments all conducted in good spirits!

    I do agree Mark's response is a little low on the signal to noise ratio :) On the other hand, I can certainly understand genuine passion.

    Cheers,
    Reza


  8. I'm afraid the attempt to see Spring as an EJB 3 container, with users "communicating via the JCP based EJB 3 standards" (whatever that would mean in practice) is fundamentally flawed. It misses the very point of the project.

    Spring's value proposition is the constantly evolving Spring Way that our users work with – not serving as "hidden backend" underneath some static spec. In other words, Spring provides many API-level and configuration-level features that can only be appreciated if you look at Spring's programming and configuration model natively. If you see Spring purely as an EJB-supporting container, you're missing the sweet spot – a typical example of a comparison that is short-sighted through the limiting perspective that it takes.

    Spring 2.5 on Java EE 5 certainly comes closer to a unification of the programming model, with EE-5-infected Spring Beans not looking radically different from EJB 3 Session Beans and Message-Driven Beans when looking at the Java code. However, that's a limiting perspective again. If you look at runtime semantics, you'll find many differentiators: Spring's unmatched support for externalized configuration that is both flexible and concise; Spring's classic singleton scope which still doesn't have an equivalent in EJB 3.0; Spring's immensely powerful AOP support; Spring's transaction management and messaging approaches that open so many options beyond the standard J2EE way; etc.

    So my point is: Don't start with EJB 3 as the benchmark – and don't just compare the programming model from the perspective of the Java code. Compare the overall environment handling, runtime semantics, configuration power, integration power – ideally in a real-life enterprise environment. Take Spring as a distinctive 'native' approach, with lots of unique capabilities on its own. Otherwise, your comparison will be hammering Spring into a limiting EJB 3.x frame, losing sight of Spring's distinctive advantages on the way.

    Juergen


  9. "Spring's raison d'être was J2EE (EJB 2.x)."

    That was part of the original motivation for Spring but by no means the defining characteristic. Right from the start, Spring provided its distinctive own programming and configuration model, very general and very flexible, *adapting* to J2EE environments very nicely but immediately transcending J2EE as well. There is a lot of non-J2EE usage of Spring out there, even and in particular in enterprise environments. This trend has been showing for years, with the rise of enterprise OSGi as the most recent indication.

    That said – Spring is still very supportive of traditional J2EE runtime environments, more so than anything that comes out of the JCP these days. Spring 2.5 still supports J2EE 1.3 , bringing the full power of Spring's Java 5 support (including the annotation-based configuration model) into J2EE 1.4 environments such as WebLogic 9 and WebSphere 6.1. This matters a lot to enterprise software development in the real world, where J2EE 1.4 will remain a mainstream deployment platform for years to come.

    Juergen


  10. Juergen:

    The sad part in this is that I clearly pointed out all of what you said in the analysis. It is just unfortunate to see a needless lashing out just because I did not choose to make the exact decisions that someone in the Spring team would have made on some small stuff that's pretty gray. However, I will choose not to judge an entire community based on the opinions of one or two people, even if they are key leaders in that community. Let's not let suspicions rein over goodwill guys :)

    However, I'll let the evidence do the talking as to my "bias". Mark, please also kindly make sure to list what XML configuration beyond that one XML attribute you thought was "verbose" I'd like to make sure I capture all your concerns for the "puzzler/solver". I think it will add great depth to the analysis.

    I am still not sure how you established why it is so difficult for Spring to support EJB 100% as well as it's own extensions. No one said you could not push out additional Spring versions on top of the specification timeline (a one or two sentence explanation, if possible, would be nice). Coming back to Dario's point, why make developers choose between meta-models at all? Folks should be able to use Spring as a fully compatible EJB 3.x container if they so choose…what's the motivation here? How does this help developers?

    Reza


  11. Reza>> I do agree Mark's response is a little low on the signal to noise ratio :) On the other hand, I can certainly understand genuine passion.

    Reza, this is not really about passion (although there is plenty of that in the Spring project). On what basis is there a low signal to noise ratio in this post? I can only guess that your comment to that effect is there to help sidestep the fact that Mark has a bunch of valid points. Now as Mark said, some of the things he talks about are Spring 2.5 features, but much of this would apply to Spring 2.0, out now for more than a year…

    FWIW, I actually remember reading an online version of your presentation back in June, and wincing at the inaccurate picture it portrays…

    Colin


  12. Colin:

    Thanks for your comments. To summarize and repeat myself in hopes to stopping this from turning into an endless spiraling thread:

    1. I'll update my presentation to reflect Spring 2.5 once it matures. Before that, it makes little sense for me to do anything further other than mention it cursorily.
    2. I'll update the presentation to use JPA support in Spring 2.0. Honestly, I think this will make little difference to the overall high-level conclusions or the general flavor of the code.
    3. There is actually very little other in this post that I see as actual reasons to modify the presentation any further (of course this is a subjective evaluation). If it is really productive to do so, I will be happy to state my reasoning *only once* on each point and hope that we can agree to disagree.
    4. That being said, the points that I see as gray areas, I will format into a puzzler/solver (with my viewpoints embedded into the solver part) and add as an interesting supplement to the presentation (I’m assuming that this is OK with you guys). I think that is pretty fair and square. Given the amount of stuff I am juggling at the moment, this won't happen until after thanksgiving. I'll be happy to post the puzzler/solver for you guys to review here. I have no problems listening carefully to reasonable requests at that point as well.
    5. Frankly, I don't know what you are talking about on the June presentation. If you care to elaborate, I'll be happy to listen. The presentation's summary decisions have remained unchanged since Debu and I took the pains to carry out the analysis quite a few months ago. The only recent "update" is that we've managed to make some space by taking out Hibernate altogether (the original comparative analysis was on EJB 3, Spring Hibernate, which are the stacks a majority of people are interested in) and add in architectural/philosophical concerns not reflected in raw code (standardization, extensibility, pluggability, deployment, development). In the past, I briefly talked over these issues (probably around June) since I didn't really have time to cover them beyond a much distilled level. Please remember that the slides only capture about 25% of a presentation.

    I hope we can leave this thread on a positive and productive note at this point.

    All the best,
    Reza


  13. Reza

    1. Spring 2.5 is final today.

    Rgds
    Rod


  14. [quote comment="63854"]The sad part in this is that I clearly pointed out all of what you said in the analysis.[/quote]

    In all fairness – you haven't. Aside from me responding to Dario's comments there and not to the content of your presentation in the first place, you seem to have missed my main points. There's a very different spin in my perspective.

    [quote comment="63854"]I will choose not to judge an entire community based on the opinions of one or two people, even if they are key leaders in that community.[/quote]

    I would argue that our opinion is as fair and balanced as yours. The key difference is that we 'natively' see things the Spring Way, while you tend to see everything from an EJB3 perspective. Frankly, I don't think you're seeing what Spring is really about.

    [quote comment="63854"]I am still not sure how you established why it is so difficult for Spring to support EJB 100% as well as it's own extensions. No one said you could not push out additional Spring versions on top of the specification timeline (…)[/quote]

    Nobody ever said it's "so difficult"; that's a gross distortion in your perspective. It is just not generally recommendable to our users. Spring differs in the defaults and recommendations from virtually everything EJB3 defines, so this would break with much-loved key elements of the Spring Way. And the Spring Way is what matters to our community.

    Anyway, the term "extensions" clearly highlights your narrow perspective again: Spring is not about extending EJB3 in the first place. Spring is about a comprehensive, self-sufficient component model in its own right, integrating with EJB3 (if desired) but not being tied to it. If we decide support standard annotations, then we do so in the context of Spring's native component model. Not the other way around.

    [quote comment="63854"]Folks should be able to use Spring as a fully compatible EJB 3.x container if they so choose…[/quote]

    The Pitchfork project is exactly about building such an EJB3 container on top of the Spring core framework. However, the point there was to implement an EJB3 container in the first place, to be embedded in server products. This is not the typical Spring usage scenario; to the best of our knowledge, our users still prefer to use Spring natively.

    In general, if folks want to use EJB 3, then they get themselves a Java EE 5 server; they don't choose an application framework for that. In other words, application frameworks integrate with EJB3; they are not themselves EJB3 containers. This applies to e.g. Seam just as much as it does to Spring. It even applies to the emerging Web Beans!

    Spring works nicely as an application framework on top of a Java EE 5 server, and will be able to do an even better job there on Java EE 6. This is exactly because Spring is designed the way it is, integrating with Java EE facilities rather than implementing them. If the Spring application framework was an EJB3 container itself, it would conflict with the built-in EJB3 container of the underlying server, while not being able to provide the added value that it does at present… So what exactly would be the point?

    Juergen


  15. I noticed Spring 2.5 is out. As I mentioned, I'll update the presentation ASAP. I think it is still instructive to deal with the viewpoints you guys have posted vis-a-vis the current presentation, so I'll post the puzzler/solver as soon as I can anyway. I think that is the most constructive way to deal with our disagreements.

    Thanks in advance for your help and comments.


  16. Hello,

    I'm one of the guys that attended the meeting and honestly I was disappointed by the quality of the presentation because I was hoping to see a more constructive comparison other than trying to bash Spring product. I share Mark's point of view and probably Reza should be more careful before making bold statements about Spring or other technology or at least try to investigate before claiming how great is one product vs. other.

    Anyway, good luck promoting EJB3 and keep up with the good work Spring team!

    Thanks,
    Valy


  17. Hello Mark,

    You are correct. I have been using Spring framework for a while and I find it is one of the easiest frameworks to use. Also it provides every thing what EJB can provide. But, community is always comparing these two technologies and blaming each other. Please help each other and try to improve the technologies and it will be good for the developers.

    Thank you for the article!!

    Thanks,
    Krishna


  18. 10. With EJB as a standard, you can migrate from one vendor to another. With Spring, you still have to port the metadata.

    I want just to comment this point.
    Who told something like this,never tried to run the same EJB on Bea Weblogic , Glassfish , and JBoss.
    Any project needed different configuration and different annotations sometimes, and i had only 1 Entity and 1 MDB… was really frustating.


  19. I've been around since the birth of Delphi so reading this is both interesting and frustrating.

    The passion and enthusiasm is great but I'm certain that behind all of these cordial posts that there is self promotion (of self and/or technology) – politics in other words.

    The overwhelming result of reading all of these posts was 'who cares except the people who are competing'. I've been using Java for 12 years and was an evangelist but have always found the arguments around the best way to do things trite compared to actually getting it done (with value) for your business.

    For example does Spring or ejb3 make web applications as fast (and consequently as inexpensive) to develop as traditional GUI's and if not what will? Will a combination of tool sets and marketing solve this problem, and if so, why aren't you collaborating to give me that solution instead of sitting in your own camps arguing (and trying hard to hide it)?


  20. I'm really interested in the Java User Group. Do you know if there are any in UK? I haven't been able to find any.


  21. in one of project client made decision to move from ejb 2.1 to spring 2.5 for sorting out performance problem…
    Is this the right decision? how do I bench mark the migration..my question was it a right to move to ejb3 rather or something else?


  22. here is the link who really wants to know, how ejb 3 can be handy over spring
    http://a-developer-life.blogspot.in/2010/11/ejb3-vs-spring.html

7 trackbacks

Leave a Reply