I am using Spring framework for the last 3 years and I am very happy while working with Spring.
In the very beginning when I started learning Spring I felt like "OMG, without doing much by myself I am getting so much of functionality".
Once I configure basic infrastructure setup like DataSource, JMS, Email Config etc I am able to perform the actual tasks like database operations or sending emails using Templates very easily. I just liked Spring framework magic even without fully understanding how it works.
Later I started digging into internals of Spring by looking at the source code and got a fair idea on Spring framework and I just loved it and now I addicted to Spring.
When I asked myself what makes me to like Spring so much I got the following reasons:
1. The most important reason for why I like Spring so much is its least surprise principle. In most of the times Spring behaves as expected and as documented in its reference documentation. For the beginners Spring has a number of sample applications for each of its modules like Spring core, MVC, Spring Data JPA etc. They just work fine. You run the Maven build and run the application it just work as expected.
2. Detailed error descriptions. When Spring throws an error it will give you very detailed description about why the error occurred. This saves a lot of time and allows the developers to proceed further without getting frustrated in the beginning itself.
3. Spring is moving towards the future(unlike JavaEE trying to catch the present).
Recently I spent sometime on Groovy and Grails and they are amazing. We all know Spring is the underlying technology on which Grails is built.
Suppose if an application can be developed by writing 1000 lines of code with Spring we can develop with 250 lines of code and with Grails we can finish it in 100 lines.
Of course the number of lines is not a good metric to evaluate the quality of a framework, what I am saying is Grails already had built in support for the regular use cases. For example we can develop Rich User Interfaces using RichUI plugin very easily.
I can list down other 100 reasons why I like it so much but these are the immediate things that comes to my mind.
Now why I hate JBoss:
Long time back I got to work on JSF1.x and at that time I tried to change my platform from Java to anything else which doesn't have JSF :-). But by Gods grace I got rid of the situation and still working on Java platform. After that I never tried JSF.
Recently I am seeing many blogs like "How to migrate from Spring to JEE6", "Time to Migrate from Spring to JEE6", "Do we need Spring when JEE6 is providing everything". I know JEE6 far far better than earlier versions and it has many features inbuilt that Spring is providing.
I felt like "Oh..JEE6 becomes that simple...I should give it a try". Then I spent sometime on reading JEE6, yeah now using JEE6 is pretty simple. I started doing very simple POC using JSF2, EJB3, CDI, JPA using Glassfish server. Amazingly with in 30 min I was able to complete the POC and its up and running. Wowwww..
Then I started doing another POC using JSF2, EJB3, CDI, JPA but this time using JBoss6 as I thought of using RichFaces4(I know I can deploy RichFaces on Glassfish also but still I thought of using JBoss6).
I followed their reference documentation and added the richfaces jars to classpath and deployed the application and then the show started.
It gave errors as it depends on some Google classes which are not there on classpath. Then I search for the jar containing those classes and got so many jars list containing those classes. I tried with each jar and nothing worked.
After a while I thought of downloading richfaces sample applications assuming either sample apps contains those jars or it may declare those dependencies in pom.xml. I downloaded the richfaces samples and eagerly unzipped it and opened the pom.xml for the dependencies. I doesn't declare the dependencies in the pom and it is referencing to a parent pm file. I thought oh ok, dependencies might be declared in parent pom file. Then i checked parent pom...f*ck..parent pom file is not there in the downloaded bundle. WTF.
Then after googling for 20 min finally i found one article on what are the dependencies for using richfaces-4. Finally i was able to run my application.
By that time I was frustrated and my zeal to experiment on various cool UI widgets that RichFaces is giving was evaporated.
The reason why I am telling all this is
"I agree JBoss AS is great open source app server that comes for free, JBoss technologies like RichFaces, Drools etc etc may be awesome. But with your poor documentation, negligence on usability the developers are getting frustrated before tasting the sweetness of your great technologies. By poor documentation what I mean is when Richfaces depends on some other jars why don't you mention it in the documentation. You should mention it and if you can mention the maven dependency that would be great. By 'negligence on usability' what I mean is you gave a sample applications zip file referencing a parent pom file which is not bundled in that zip. Once you uploaded the samples if at-least once any of you tried to download and use the samples you might realize the absence of parent pom. You just uploaded samples without checking at-least once."
With all this how I feel is unless my employer insisted me to use JSF/RichFaces/EJB3 I will never use them.
When two(JEE6/Spring) technologies can do the same thing I would go with the technology(Spring) which just works as expected.
I wonder if anyone can write an application using JSF/EJB/CDI without having Google and StackOverFlow(because you will definitely face weird issues and after struggling so much of time you will find a solution in StackOverflow) :-)
But I can write an application with just Spring reference documentation :-).
"SPRING ROCKS"
I'm sure you meant well when you tried to compare but I don’t know how you did the comparison I think you should read about application servers before doing the comparison. Spring and Application servers are used for totally two different things.
ReplyDeleteHi Jason,
ReplyDeleteI am not comparing Spring and JBoss Server.
Spring is a framework and JBoss is an Application server.
I am trying to comparing the ease of use for Spring and JBoss technologies like RichFaces, Drools etc.
Hi Jason,
ReplyDeleteCan you explain this:
"Spring and Application servers are used for totally two different things"
It sounds weird
How does it end up on dzone!!?
ReplyDeleteI guess we all had bad experience with tutorials, but no reason to write this..
JBoss > Spring
@Jason
ReplyDeleteManyny people talk like application servers are something special that only JEE technology makes possible. "Application Server" is not some kind of trademark owned by the JCP group. Actualy there are no application servers! only http servers, ftp servers and so on. The JEE application server model is just a framework bolted on top a real protocol server. By that definition Spring + Tomcat is also an application server. Apache + PHP is an application server too.
I got my first RichFaces app running very, very fast. But then again, it was RichFaces 3. While you have a point the JBoss docs tend to suck (mainly because they don't exist), the title of the article is horrible... It should have been "why is documentation so good" or something...
ReplyDeleteWhen I first joined my current work, we were using JBoss server for development and deployments (version 4 IIRC). Startup times were dog slow and in general productivity was very low. Since all our projects were Spring based I proposed to evaluate Tomcat at least for development. There were some oppositions at first but were diminished by the evident boost in productivity. We now use that setup for both development and deployments and are happier than ever. Had we locked ourselves to JEE we could not have made the jump. So yeah, Spring rocks, JBoss bites.
ReplyDeleteI agree that Spring rocks but this article doesn't make sense. I have successfully used EE technologies on top of Tomcat which is NOT an EE server like JBoss. Also, using Spring does not prevent you from using EE technologies. I have used Spring WITH EE technologies like JPA, JSF2 with no problems.
ReplyDeleteThank you very much for this useful article
ReplyDeleteHis comparison isn't crazy.
ReplyDeleteA spring app and a Jboss app have very similar goals in enterprise dev. His experience with Spring is easier and I would agree. As an integration tool where you use only what you want, it's ideal. In a way, you can view Spring as the first implementation of the "profiles" concept, but with waaaaay more options so you only use what you want. Jboss isn't like that at all.
I think the point of your post is that you have found it difficult to write Java EE 6 apps due to lack of JBoss documentation whereas you feel that the documentation for Spring is superior and more comprehensive?
ReplyDeleteOne thing you must remember is that Java EE is a standard (lets forget about RichFaces at the moment) so if you can't find JBoss documentation, you can read EE documentation from Oracle or IBM or whoever and usually you can apply it to JBoss.
I've been developing with Spring and EE for a long while now and there is good documentation about both, including specifics for JBoss if you need it. I've found that both Spring and JBoss have very good active communities that will help if you ask.
"I followed their reference documentation and added the richfaces jars to classpath and deployed the application and then the show started.
ReplyDeleteIt gave errors as it depends on some Google classes which are not there on classpath. Then I search for the jar containing those classes and got so many jars list containing those classes. I tried with each jar and nothing worked."
You don't use anything like maven or ivy?
I've always had better experiences with documentation, ease of use, etc. with JBoss than Spring. YMMV.
ReplyDeleteLet’s do a comparison between Spring and an Application server first. I'm sure this will help all.
ReplyDeleteYes I agree that Spring and AS have a lot in common, but there are key differences. First thing you need to know is Spring beans are singleton (more or less in a context point) Spring does not handle threads (create) it only helps you to manage beans (injections) and most importantly mange transaction. Spring makes the developer control all the threads.
Can anyone tell me the most important feature in an application server? and why we need it?
"It's global transactions" let’s get that cleared first. If any developer here have worked with two or more JVMs which need to communicate and on top of that if they need to make multiple DB calls to mysql, orcal and on top of that make sure the transaction are managed and when one fails all has to be rolled back then you will know why you need a AS.
Spring only supports Local transaction and not global transactions if you don't believe me check the documentation (http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/transaction.html)
On top of that all AS manages threads for you. all threads are pooled you can integrate from UI all the way upto DB calls without considering the threading because AS give you the flexibility to only think about the logic and not how its executed.
In any way I'm not saying Spring is not good. I love spring I worked with spring more than any AS but it is wrong to think that Spring can replace an AS usage, but if you want to think about all the AS logic in the application and integrate spring to it yes It can replace it but that’s just reinvention the wheel :)
If the application is small yes spring is the best choice :)
One last thing just because documentation is bad that does not mean the product is, Spring documentation also was really bad couple of years back.
@Jason
ReplyDeleteRead that documentation again. Spring supports JTA transaction management transparently as well. In fact transaction management is built on top of Spring's powerful AOP features which, unlike JEE, are also available for use in your own code at will. Transaction Management == AOP and despite what companies say AOP does not an Application Server make.
Beans having singleton scope has nothing to do with the framework's ability to manage resources across threads. These kind of resources are not being carried in the state of those beans (and shouldn't). The default singleton scope is good for many reasons. It is best for performance but most importantly it promotes good stateless designs.
@koumparos
ReplyDeleteUsing two dataSource, two txManager, two txAdvice and defining distinct elements with differing 'pointcut' and 'advice-ref' attribute values would allow to apply totally different transactional configuration to different service layer objects/methods.
See section 9.5.4. Configuring different transactional semantics for different beans for the details. (http://static.springsource.org/spring/docs/2.5.6/reference/transaction.html#transaction-declarative-diff-tx)
But if you need to work with multiple transactional resources (typically relational databases and message queues), then you need global transactions support which means a J2EE transaction manager (provided by a J2EE application server or standalone like Atomikos, JBossTS, JOTM, etc).
In any point I did not say singleton is a bad approach. I’m just saying if you’re going with Spring the developer need to take control of the logic in his hand (sometimes this is good) but with AS this is already done for you.
Indeed Spring rocks. One of the best Java framework in present time. It not only provides lot of utility methods required to build an enterprise application but also enforce good coding practice in terms of dependency injection and IOC. I have also shared some tip on Spring security as Ldap Authentication in Active Directory using Spring Security you may find useful.
ReplyDelete