In light of some criticism and even attacks (justified or not) that are out there, here are the ten most common misconceptions about Spring from SpringFramework.org.
The Ten Common Misconceptions About Spring
For those new to the Spring Framework, we feel as though it is necessary to address some of the concerns you may have when approaching Spring for the first time. In fact, we have compiled this list based on our collective experience in training new Spring users and observing discussions and forums throughout the Java development community. It is our goal to shed some light on these issues so that you will be better equipped to make well-informed decisions regarding the adoption of Spring on your next project.
1. Spring is not lightweight. It aims to do everything and is becoming fat and bloated.
Spring’s primary goal is to enable lightweight development based on POJOs. As a developer, you should be able to focus on your domain-specific business logic rather than infrastructural issues and convoluted contracts. You should be able to rely on the framework to solve your integration concerns. However, when building enterprise-class applications, there can be an abundance of such concerns. So in a sense, Spring does aim to do everything that you - as an enterprise developer - might expect an enterprise framework to do. Spring supports such a vast array of enterprise services and third party products that it may in fact seem fat and bloated at first.
However, in order to provide a comprehensive integration platform for enterprise software development while simultaneously supporting full stack POJO-based development, the Spring Framework has been designed from day one to be non-invasive and modular. You can and should choose only what is needed for your particular project, but as requirements evolve, you can incrementally add (or remove) modules. The Spring team emphasizes keeping things as simple as possible. This applies to Spring itself, and most importantly to applications built with Spring.2. Spring is overkill for simple applications.
As mentioned in the previous point, the Spring Framework can help you to keep things as simple as possible. You can use only what you need initially yet adapt and extend your application as requirements become more clear. It makes sense that such an environment provides favorable conditions for simple applications.
For one thing, even simple applications typically require some enterprise services such as transactional database access. In that case, the simplest option may be to rely on Spring’s data access integration and declarative transaction management. Furthermore simple prototypes have an uncanny way of transforming into production applications. If you are responsible for such an application, you will appreciate a lightweight yet scalable framework that can handle those demands.3. Spring does not scale to handle very large applications.
Spring is used for very large applications by hundreds of the biggest corporations in the world. The Spring Framework is well-established in the enterprise development space where it is meeting the demands of applications for banking, government, and the airline industry.
One example is Voca, whose services are used for payment of household bills by over 70% of the UK population and for paying over 90% of UK salaries. They’ve relied on Spring to process over 5 billion transactions in 2005 - with over 72 million on a peak day.
Other acknowledgements of increased productivity and performance for large scale Spring-based applications include an online system for the French Taxation Office built by Accenture and an enterprise application of the European Patent Office. (SpringOne 2006 Keynote, Antwerp, Belgium)4. Spring forces you to use Aspect-Oriented Programming (AOP) which is experimental.
Some of Spring’s powerful capabilities leverage a technique called Aspect-Oriented Programming or AOP (see chapters 3 and 4), but as always you can choose whether or not to use those particular features. Furthermore, Spring 2.0 has significantly improved its AspectJ integration which means there is an increasing range of AOP options to choose from. Many users become comfortable with the core concepts by using Spring’s proxy-based AOP and then begin applying AspectJ when the extra power is necessary.
Before letting FUD guide your decision-making process, there are a few things you should know. First, Spring’s proxy-based approach to AOP relies on the use of standard JDK dynamic proxies. That means that this functionality is actually enabled by the core Java language. Second, AspectJ is the product of many years of research, and is now a well-established de facto standard. Third, AOP is very focused on a particular limitation of Object-Oriented Programming and is therefore best viewed as a complementary rather than revolutionary technique.
Traditional OOP is unable to modularize certain “aspects” and thereby leads to code duplication and scattering of orthogonal logic such as auditing, security, etc. Once you overcome the initial learning curve (which is surprisingly easy once you break through the FUD), AOP is a very natural approach to solving that problem. For example, in a Spring-based application, you can provide transaction management to your entire service layer without modifying any of the code. That means the application is more flexible and easier to maintain while the code is kept clearly focused on business logic. Based on that and similar capabilities, you may join the increasing number of developers who are more than willing to begin experimenting with AOP.5. Spring replaces Java Enterprise Edition (JEE).
This is one of the most common misconceptions about Spring and yet one of the most misguided. In fact, Spring is largely about Java Enterprise Edition (JEE) integration. Spring offers a compelling alternative to the traditional, heavyweight Enterprise JavaBean-based component model while still leveraging the full power of the other JEE standards. One motivation is to simplify the usage of JEE APIs so that developers are not forced to repeatedly write extensive amounts of code. Another motivation is to encourage decoupling of application code from the JEE services. Spring offers a consistent approach to promote productivity, and where applicable, Spring provides abstractions to promote flexibility.
Spring’s integration support for JEE APIs includes:
· Java Message Service (JMS)
· Java Management Extensions (JMX)
· Java Transaction API
· JEE Connector Architecture (JCA)
· Java API for XML-based Remote Procedure Calls (JAX-RPC)
· JavaMail
· Java Naming and Directory Interface (JNDI)
· and Enterprise JavaBeans (EJB) including version 3.
Support is also provided for some very important Java Standard Edition technologies such as Java Databae Connectivity (JDBC) and Remote Method Invocation (RMI) as well as JEE 5 additions such as the Java Persistence API (JPA or the EJB3 persistence specifications). Spring consistently applies this same approach for integration with well-established third party products such as Hibernate, iBATIS, Quartz, Hessian, and so on.
Spring’s JEE integration is never based on the “lowest common denominator” approach. On the contrary, every effort is made to preserve access to the full power of the underlying technologies. In other words, while recognizing that 80% of the time you only need 20% of the functionality - the remaining 80% is available when needed.
For in-depth coverage of this particular topic, see “Expert One-on-One J2EE Development without EJB” by Rod Johnson and Juergen Hoeller.6. Spring and EJB are mutually exclusive.
In the previous point, we described Spring as “a compelling alternative to” EJB. However, Spring promotes choice - including the choice of using EJB. Spring provides support classes for implementing EJBs and providing them with access to the managed beans of a Spring container. Spring also provides a configurable proxy mechanism that allows EJB client code to have dependencies only on simple business interfaces. The details of EJB remote access, JNDI lookups, and the associated exceptions are all hidden behind the proxy and managed by Spring. That abstraction is very useful for integrating EJB-based legacy code with newly developed POJO-based code. Since the client is no longer concerned with those details, this approach also provides a convenient migration path between EJBs and POJOs. Interestingly, if you choose to use EJB3 and the associated POJO-based model for persistence (JPA), you will likely find the migration path from a Spring-based application to be much smoother than from an application based on an earlier EJB version. Furthermore, with Spring you can take full advantage of JPA without using any other features of EJB3 if you so choose.7. Spring cannot take advantage of Java 5 annotations like EJB3 does.
Pitchfork , an add-on for the Spring Framework, supports JSR-250 and a subset of the JSR-220 (EJB3) annotations. Pitchfork is a result of collaboration between Interface21 and BEA and is published under the Apache 2.0 license. It not only provides the foundation for WebLogic’s EJB3 implementation, but it also enables extension of the EJB3 programming model via the Spring Framework.
Core Spring 2.0 provides full integration support for JPA (EJB3 persistence) including its annotations. Spring 2.0 also adds support for @AspectJ-style annotations. Other annotation support in Spring includes transaction management, JMX configuration, and dependency validation.8. For a large application, Spring’s XML can become a maintenance nightmare.
If not managed properly, Spring XML files can indeed become too hard to edit and too easy to break. Here we point out how using the right tools and the right techniques can address some of the specific issues you may encounter:
too error-prone
Using the proper tools is essential. An XML editor provides code-completion and validation by leveraging a DTD or XML Schema Definition (XSD). One of the major focuses in Spring 2.0 has been on XSD-based configuration which provides considerably more information to the editor. Spring-specific IDE support as provided by IntelliJ or the Spring IDE plugin for Eclipse adds even more, such as providing completion of Class names and suggesting properties available in bean definitions. If you choose the names from a dropdown list, you will save time and you will not produce any typos.
too difficult to navigate
XML files should be split up to reflect the structure of your application’s modules. As with your code, it makes sense to keep related configuration information together and have clear separation of concerns.
too cumbersome for simple properties that may change frequently
Certain key/value pairs should be externalized into property files. This prevents that XML files are modified every time one of these simple properties needs to be modified. Spring provides configuration options that will make those properties available to the bean definitions that require them (see chapter 5).
too repetitive
Bean definition inheritance can reduce duplication any time common properties are being set on a large number of related objects. As an example, a single “dataSource” bean definition may be fulfilling a dependency of many data access beans. In that case, an abstract parent bean definition can capture that shared property in one line.
too generic
A major addition in Spring 2.0 is XSD support and domain-specific namespaces. These enable more concise formats for many commonly configured items. It is also very easy to create custom namespaces to provide domain-specific configuration of your own bean definitions or for integration with other frameworks.9. Spring does everything with reflection, so it is slow.
Spring does not do everything with reflection, but it does make extensive use of reflection. Therefore, we want to clarify the role of reflection in Spring and discuss the performance characteristics of reflection in general.
Spring uses reflection for its Dependency Injection, but it is important to understand that this occurs only at configuration time (when beans are wired together). From a performance perspective at runtime, it is no different than if you had explicitly set the dependencies in Java code.
Spring uses reflection via standard JDK dynamic proxy objects in its Aspect-Oriented Programming framework. Typically these proxy objects are configured at the coarse-grained service layer where they provide features such as transaction management, security, or exporting objects via remote access. If the call and execution of methods on a proxy object involves the network and/or database access, then the performance impact incurred by the proxy’s use of reflection will be negligible.
In any case, decisions motivated by performance concerns should always be based upon relevant benchmarks rather than intuition or hearsay. If you are using Java 1.3, then some of the traditional concerns about reflection may be valid. For example, in the 1.4 release of Java the performance of the reflection API was improved by 2,000% .10. Spring MVC is complex and not as simple as the rest of Spring.
Spring MVC is highly-configurable and highly-extensible due to its interface-based design. It uses well-established design patterns such as the strategy (e.g. ViewResolver) and the template method (e.g. SimpleFormController). Unfortunately it is easy to mistake configurability and extensibility with complexity. As with all things Spring, you can and should use only what is needed, but you will benefit considerably by taking some time to learn what options are available. You will be pleasantly surprised to discover just how simple and well-defined each Spring MVC component is. Each cohesive unit is focused on one small part of the lifecycle of handling an HTTP request and rendering a view. This promotes decoupling of business logic from presentation logic which in turn leads to applications that are powerful yet flexible. Once you use the Spring MVC framework on a project, you will most likely appreciate its power and ease of use. It is actually quite easy to implement a small, simple project with Spring MVC.
What do you think? For more on the new Spring 2.0, here’s a good resource as well.

I agree with most of what you've said - I find Spring suits my needs pretty well, and some of the new stuff in 2.0 is really useful.
Not so convinced about MVC though. To be sure, there are much more complex frameworks out there, but I don't find Spring MVC scales well in terms of maintainability. It's simple enough to develop a single screen, but once you start to get lots of screens, I find I end up having to develop extra infrastructure and new base classes to avoid duplicating code all across the different screens.
Then again, I'm not sure if other web frameworks handle that much better.
I started doing web programming for the first time about 5 years ago, and quickly realized that it can get complex pretty quickly no matter what language or framework you were using. That's what drove me to find a solution like the Spring Framework. I was very happy to find something that can scale up as well as down with relative ease and little complexity. I still use Spring to this day for most of my projects, but if I had to make a complaint, I would say that I could definitely benefit from more automated tools. For instance, it would be nice to create a bean, right-click on it in my IDE and automatically add it to an applicationContext.xml along with good guesses of its dependencies. There are other types of functionalities I can think of that would just ease the development process. I use the SpringIDE in Eclipse, and it helps but it's just not up to the point where it does a LOT for me. I don't mind if a tool makes assumptions especially when I am trying to rapidly develop something. Other than that, I think the Spring Framework is truly a good piece of software, and I would have to agree with all 10 of this guy's points.
Spring is a solid piece of engineering. Unfortunately some people take it to be a magic bullet. It is excellent at making an application testable, robust and flexible. But like all great technologies it is merely one of several good ways of doing things rather than the one and only.
Well, I spose it's only valid to address the misconceptions that are likely to result from the alleged misconceptions....
1 - Spring is NOT lightweight, if you mean lightweight in some kind of absolutist sense. It's lightweight compared to a full blown container, but is not lightweight when you factor in the fact that you have to write beans, write lots of xml, and have spring do its 'magic'. This is now akin to server startup time.
2 - Spring IS overkill for a certain class of simple applications. In many cases, there's no need for all the wiring magic to be externalised into a configuration file.
3 - Spring does scale, fair enough. It won't do so magically though, you still need to know how to make it scale, it doesn't solve the scalability issue for you; you still need to be a smart developer to do that.
4 - Are there STILL people out there who care about AOP??
5 - This I can't argue with. Though the Spring layer that goes on top of many of the core EE API's are their own form of vendor lockin.
6 - Spring's JPA support is still not entirely pleasant, though this will likely improve over time. Spring does play nice with EJBs though, granted.
7 - Spring does not take advantage of annotations the way that EJB3 does. Spring's approach to annotations so far still forces you to declare all your beans in the configuration file. Granted, it's a hard problem to solve (jar scanning is a nasty business), but in an EJB3 container, it's easier to plop things in and have them work magically than it is in Spring. Pitchfork is a great step in the right direction though (I say this as a happy user of pitchfork).
8 - Spring's xml is crap. Spring 1.x XML is a compelling enough reason to avoid it altogether. With just a handful of beans it becomes a complete mess unless you have autowiring enabled (which the Spring folks don't recommend you do). 2.0 improves that somewhat, but it's still unpleasant and can grow uncontrollably. The XSD support makes validation better, but it's red herring argument. XSD or DTD make no difference to how readable or verbose xml is.
9 - Spring is slow (compared to, say, wiring by hand). I know better than to blame reflection, but 2-3 seconds startup just to scan a handful of beans with annotations and wire things up is not what I traditionally think of as fast.
I don't know much about Spring MVC so can't comment to that.
All in all, this article would have been a lot more useful if it wasn't so keen on being marketing material!
Hey Hani,
Nice of you to drop by. What we've presented here is our personal top 10 of the misconceptions we regularly come across. As you may have noticed or "marketing material" doesn't say any of the misconceptions are plain wrong. We do believe they are out of balance in the minds of some people.
I believe it's useful for developers to be able to make informed choices which is our motivation for writing this top 10. I do not intend to stop developers from using say Ruby on Rails or Grails. I certainly want to prevent them from not using Spring for the wrong reasons.
1 - Spring is NOT lightweight, if you mean lightweight in some kind of absolutist sense. It's lightweight compared to a full blown container, but is not lightweight when you factor in the fact that you have to write beans, write lots of xml, and have spring do its 'magic'. This is now akin to server startup time.
You'll be happy to learn Spring 2.1 will support configuration in Java classes as an alternative to XML. This will proves to be an extremely powerful and flexible means of configuring applications. Ofcourse you will be able to mix XML and Java configuration as you see fit. I assume you have no issues with the Spring 'magic' per se.
2 - Spring IS overkill for a certain class of simple applications. In many cases, there's no need for all the wiring magic to be externalised into a configuration file.
Granted. If you are referring to Ruby on Rails this is a great environment for simple applications. I've read "Getting Real" book and I subsribe to a lot that's being said.
3 - Spring does scale, fair enough. It won't do so magically though, you still need to know how to make it scale, it doesn't solve the scalability issue for you; you still need to be a smart developer to do that.
Do you know of any platform/tool/approach that don't require smart developers to get scalability? You know very well EJB does not scale like Spring-based applications can. This is the difference: with EJB it's going to be very hard to scale. With Spring you have a very good chance to get real scalability.
5 - This I can't argue with. Though the Spring layer that goes on top of many of the core EE API's are their own form of vendor lockin.
I don't see where this "vendor lockin" comes from. There is no more lockin by using Spring template classes than when using the APIs directly. If you're refering to JmsTemplate or JndiTemplate these are a few utility classes that can be used independently from the rest of Spring. The big difference is that you'll be able to write applications that use JEE services and avoid an entire batch of potential bugs.
6 - Spring's JPA support is still not entirely pleasant, though this will likely improve over time. Spring does play nice with EJBs though, granted.
I agree. The main problem are the JPA specs that don't properly support integration.
7 - Spring does not take advantage of annotations the way that EJB3 does. Spring's approach to annotations so far still forces you to declare all your beans in the configuration file. Granted, it's a hard problem to solve (jar scanning is a nasty business), but in an EJB3 container, it's easier to plop things in and have them work magically than it is in Spring. Pitchfork is a great step in the right direction though (I say this as a happy user of pitchfork).
It's good to hear you're happy with Pitchfork. Spring does not attempt to do JAR scanning but nothing's stopping people from writing their own additions. BEA integrates with the metadata abstraction of Pitchfork to provide easier deployment.
8 - Spring's xml is crap. Spring 1.x XML is a compelling enough reason to avoid it altogether. With just a handful of beans it becomes a complete mess unless you have autowiring enabled (which the Spring folks don't recommend you do). 2.0 improves that somewhat, but it's still unpleasant and can grow uncontrollably. The XSD support makes validation better, but it's red herring argument. XSD or DTD make no difference to how readable or verbose xml is.
I'm sorry to hear you don't think the Spring 2.0 XML Schema are a major improvement. We need more time to work out more schemas in more areas, the same goes for projects that build on top of Spring (e.g. Acegi 1.1). But the custom XML that are already available do make a big difference in XML files. Again, it's up to the user how readable their XML files are. Another big contribution to improved readability of the Spring XML files is the new integration with AspectJ Aspects.
9 - Spring is slow (compared to, say, wiring by hand). I know better than to blame reflection, but 2-3 seconds startup just to scan a handful of beans with annotations and wire things up is not what I traditionally think of as fast.
Are you referring to loading a Hibernate SessionFactory of JPA EntityManagerFactory? The Spring ApplicationContext needs much less than 2-3 seconds to load a handful of beans.
Anyway, thanks for sharing your thoughts and ideas.
Spring in particular and IOC in general is nothing but one of the GOF's original design patterns misrepresented, and then obfuscated behind XML to boot, just to make a handful of consultants a sh!tload of money
The whole XML configuration files issue can be very easily solved by using XDoclet. I'm suprised it's a solution thats not more widely used. We use it with a relatively large team of developers and it works very well.
Chris, xdoclet is the worst possible solution. You end up with all the downsides and none of the upsides of annotations vs xml.
1) It's loosely typed and error prone (comments are NOT code)
2) it's tightly coupled to source code
So you lose the flexibility of having an external xml file to drive configuration, and you lose the type safety of annotations.
With JDK5, there's no sane reason to use xdoclet.
I feel spring provides an easier and cleaner way to achieve your objectives and there are always pros and cons with any good framework.
One can easily blame for it being crap without understanding it and fully utilizing it in a proper way and for all those of you who have problem with some guys making shitload of money, channel your energies in creating something even better as it will benifit all of us.
1. Spring is lightwight compare with Application Server.
2. EJB is overkill for any SME. ONLY large scale application (2000+ concurrent users) will benefits from it.
3. - Spring is only useful for smart developer. -EJB also requires smart developer to make it scaleable.
4. "Are there STILL people out there who care about AOP??" - Nonsense, obviously there are lots of people care about it. Aopalliance, AspectJ, Spring AOP and Jboss AOP are still very active projects leading by very smart people.
5. Vendor Locking? all template are only helper classes, they are optionals. Hani, I reckon you really need to learn spring again if you think you are already good at it.
6. JPA spec is finalised few months ago and I'm sure spring will support it in future release.
7,8. annotation - loosely typed and error prone
annotation - tightly coupled to source code
annotation is crap too.
9. For server application, startup time is not a problem at all. Indeed, hibernate startup time is much longer than spring, if you use hibernate with EJB, you will have the same problem. For development, I use mock object.
I'm so confused....so editing XML is a PITA and error prone, but XDoclet sucks because you have no control over the XML? What in the world should you do if you can't do either? :-)
FWIW, I think Java 5 annotations are replacing XDoclet (at least for Spring usage) and hopefully there will be enough annotations so we no longer need to edit XML to get Spring to work right ;-)
Hani give us all a break will you? You're only on here yourself to promote your big flapping mouth. A marketing tool if ever there was one.
[Reply to this "Subtle EJB propaganda" article, posted on theserverside.com]
I would like to point out some comments on the 10 "misconceptions."
> Spring is not lightweight. It aims to do
> everything and is becoming fat and bloated.
Spring is not lightweight. Not if you tend to use everything, that is. It's modular and scalable and will provide you with lightweight combination that suites your business.
> Spring is overkill for simple applications.
Also a questionable misconception. It is true Spring introduces a layer of complexity, but it also preserves/enforces good OOD, patterns and model, thus contributing more then it takes.
> Spring does not scale to handle very large applications.
Also quite false. My bank runs about 50 branches and with more that 1000 employees. Very large financial application is backed up by the Spring 1.2.5 and its scales quite nicely so far. We use Spring container (IoC, beans) and a bit of AOP, that's all.
Additionally, I've developed an EJB-like annotation model and created wrappers for complete Spring, thus hiding it from "daily developers" in order to prevent xml chaos and factories mentioned above. System is reliable and responsive.
> Spring forces you to use Aspect-Oriented
> Programming (AOP) which is experimental.
Well, I don't know how to comment this objectively. Neither is a complete truth. You are not forced to use AOP by no means, and it is as experimental as Spring itself.
> Spring replaces Java Enterprise Edition (JEE).
This is the only misconception I agree completely. But, it's worth mentioning that its not the only thing Spring replaces...
> Spring and EJB are mutually exclusive.
Wrong.
> Spring cannot take advantage of Java 5
> annotations like EJB3 does.
It's a simple case of metadata style that's considered appropriate by the architects. Both approaches have their good and bad aspects, not worth reasoning about it...
> For a large application, Spring's XML can
> become a maintenance nightmare.
So does any type of configuration of a large system. It's true that EJB3 annotations will prove more maintainable that Spring's XML, thought. But it has its down sides as well, and this is not the place for that story.
What is worth reasoning is the amount of pressure introduced on junior developers by xml configuration and java code metadata configuration...
All in all, "misconception" is insignificant.
> Spring does everything with reflection, so it is slow.
This is the weakest "misconception" of all. I frequently quote Mr. Knuth to my colleagues
"Premature optimization is the root of all evil."
Spring has some complex algorithms for singleton maintenance and retrieval (source is available). By no means Spring is slow due to reflection, I suggest you test your "misconception" with some benchmarking - you will find Spring slow, as I did, on some awkward places, but not in reflection code.
> Spring MVC is complex and not as simple
> as the rest of Spring.
Yes, it is not simple as the rest of the Spring and, yes, it is complex. And yes, you don't have to use it if you don't like it.
My ten "misconceptions" would address some misbehaviors and new functionalities like invalid bean querying, lack of wiring inner classes as inner beans, absence of reference wiring, no reconfiguration infrastructure etc.
Some of these misconceptions may raise valid concerns. Especially when Spring is compared with other lightweight frameworks like the J2EE Pattern Oriented Framework:
http://jt.dev.java.net/
"AOP is very focused on a particular limitation of Object-Oriented Programming"
Well, I would say it is a limitation of Java rather than OOP, basically it's poor support for metaprogramming: lack of prototypes/open classes, bad reflection support, no introductions, and so on: AOP can be implemented almost framework-less if the language is richer. Take a look at Smalltalk or Ruby which are OOP and don't need Spring. Great post, though :-)
In light of some criticism and even attacks (justified or not) that are out there, here are the ten most common misconceptions about Spring from SpringFramework.org.
I do not agree. Go to http://www.dreamsjobs.info/irrefrangible_Italy/phenomenon_Toscana/minute_San%20Gimignano_1.html
Good job !
Isn't it funny that spring is the only framework widely used for integrating different frameworks through inversion of dependency? At least I don't know another one, mature enough. There is Guice, a fresh one, without most of the drawbacks mentioned in this article, but nobody uses it yet.