Wednesday, July 30, 2008

Spring vs J2EE Application Servers

Lately I have been playing with Oc4j, Tomcat, Glassfish and JBoss, before that, I had only played with Spring and Tomcat (but Tomcat was irrelevant, it was there only to start Spring) and now I have realized why Spring is much more comfortable than JEE, even with all the enhancements of JEE5: Spring is “inside” your application, for example, if you want to connect to Oracle with Spring, you add the JDBC jars to your application, and then configure your datasource in the applicationContext.xml file inside your application, if you want to use log4dbc and slf4j to debug the SQL generated by Hibernate (BTW Hibernate .jars are also inside your application) you can do it, and you only have to modify, again, the applicationContext.xml file inside your application, if you want to add support for Spring transaction handling, or you want to expose some of your beans as CeltiXFire Webservices, you describe all that: exactly, you guessed correctly: inside your application. You really don’t care about the stuff outside of your application.

With JEE is the other way around, you have to worry about stuff outside of your application (for example, avoiding name conflicts in the JDBC datasources registered in JNDI), you have to worry about installing the Oracle .jars in Tomcat, Glassfish or JBoss (and worry about conflicts if the version installed as by default in Oc4j (or as shared in Tomcat) is not the one you want to use). You have to worry about compatibility with the way WebServices are handled and configured by your particular application server, etc.

And finally, when you want to test stuff, you have to start the all the huge application server, even if you just want to test if your Login page is working correctly and if after logging in, the right permissions were loaded in the the current session.

I think that is pretty much why JEE still feels uncomfortable when compared with Spring, JEE it is still about the application server, not about my application: and I really don’t care about the JEE application server, all I care about it is my application. I think that JEE6 (or perhaps JEE7) should focus in finding the way to take the attention back in to the application, perhaps by forcing the JEE application servers to offer their services the way Spring does it, from inside the application, and only if you want it, as a second, hard to configure option, make those services shared.

No comments: