I wanted for so long to write my thoughts about this subject.The past couple of years I have been coding entirely in projects that required an Enterprise environment and were mostly enterprise applications with exposure to the user through a Web UI. This would include high scalable mobile marketing systems , billing systems and lately workflow systems. The past year I have been developing my own idea and I came to the point where I had to take some decisions around the debate of using or not Spring in my application. The application uses as major deployment platform, WildflyAS 8.0.0 Final(fully JEE7 compliant application server) at the moment, formerly it was JBoss 7.1.1(fully JEE6 compliant application server) but I switched to the latest fully JEE7 compatible application server. Having a long history with JBoss it is the application server of choice.
I know the product since version 4.0. Despite all the criticism by the competitors, it was the only product that would give a fully functional JEE5/6/7 stack implementation for free offering also clustering. I have much respect for Glassfish also, but the RedHat way was more my way, and when I meet one of the guys I was looking up, Arun Gupta, and he told me that he was moving to RedHat to lead the developers advocacy dept, I was even more excited. I had the opportunity to talk with him while he was attending for a talk in the local Java user group in Luxembourg. Collaborating the past few years with a lot of Spring lovers, I came to question the necessity of having as production tool an application server which is, yes “heavy weight”, offers “many more things than actually need it” than what you actually need and is problematic with libraries. So I started introducing to my project with some friends Spring. Our platform is supposed to be a big data platform for real time statistics on usage of affiliate networks and other marketing stuff. I decided to give it a shoot and we started springing and tomcating everything. After some time I started to notice that the caveats of JEE5 /6 were simply transformed, in a worse manner. I took the decision to migrate everything to JEE7. In the following paragraphs I will explain my myths and realities by using both worlds.
Please, for God’s shake(in any God you may believed), in the era where commodity server for deployment of a testing environment is a cluster of 4 nodes with 3 i7 8core CPU with at least of 16GB or RAM each, talking about memory consumption can only sound funny. On top of that I would add, have you ever tried to simulate a JEE environment with Spring and a Servlet(Jetty,Tomcat) compared to that of full fledged application server. I can tell you that in our case it was nothing but a few megabytes more on the application server side.Yes the application server is heavier in terms of memory.No argue about it, but in production systems in big data centers where maintainability and support is more important, Tomcat isn’t a choice. Check for example the switch European Comission is doing migrating every application in full JEE application server from Oracle. And for those of you out there, Servlets are NOT application servers. The fact that you simulate all these by using Spring is a naive approach. TomEE a ,very nice try @dblevins is a big effort and works really good, to bring JEE stack in Tomcat in the correct way by following the specification. Please also bare in mind that the simplicity of the configuration of an application server for a starting developer is far more simpler than Spring. The simplicity of the tools should attract and not the hype around it. By the way have you tried to cluster Tomcat farms? Have you given a shoot of Wildfly 8.0.0 .If not before deciding I urge you to give it a shoot.
Many more things than…
The application server loads far to many things. Another big myth, evangelized by several Spring guys. All application servers, these days offer several profiles for starting up with different level of services. All these are configurable. In my environment with the full configuration of Wildfly, the application server starts and deploys the entire stack of my application in less than 20 secs. Other products like Glassfish offer the same capabilities. Profiles are now a major standard for the JEE community and bring the JEE one step further. In the same configuration with enabling the same spring contexts for the same services it was 14 secs for a Tomcat. That didn’t include initialization of the transaction management. This would lead in a difference of 4-5 secs. I rest my case on that, yes is a bit faster…BUT I had to boot up hornetQ myself and Mule ESB myself + Camel. Adding these boot times you are in the same boot times and of course the manageability of your environment now becomes far more complex. In order to simulate that and be more accurate, I enabled the managing of HornetQ through the Spring context. Doing that, voila, the magic is gone. The environments are equal the need the same time +/- 1 sec to boot up everything end to end. Have you tried to configure all these things alone?Bet you, that at some point you will be frustrated. Using JEE7 and a fully compliant JEE7 application server like Wildfly 8.0 or Glassfish, the only mandatory things is the definition of dependencies and to know the deploy folder. The new JEE7 specification simplifies the programming and deployment model by giving the chance to Java enthusiast to focus on what is important. That is the fun of coding and creating amazing products.
Libraries and jar hell
Classloading was and remains a kind of black magic to the new comers in the java world. Endless debates have been going around for years for how application server and servlets are loading libraries. People were accusing appservers that do not respect the libraries of the users. A big hype. Since the JEE5 the loading of classes was more or less standardized. Problematic of course I will admit, but it was clear. The fact that everyone was opting the hierarchical model, was creating issues. I will admit to that.But have you tried using Wildfly and the new JEE 7 standards?Thinks have radically changed.Coming to the point of jars also, I challenge everyone to create a project using JEE7 and Spring and then list the dependencies you have. JEE7 solves this issues. No problem with mis compatible libraries and versioning. After doing the migration from Spring to JEE7 my war contains 8 jars!Yes I know you wouldn’t believe it but it contains 8 jars. Which are deps to the JEE7 API’s and to libraries I have created. Have you tried maintaining different libs than what Spring would ask you to and try to solve the version conflicts, because the framework A wants a version X of a jar and Spring requires version Y? I know it looks like trying to solve the typical assignment problem in computer science with JARS as resources. With JEE7 adoption,you will only need to reference the API’s and let the appserver provide the implementation. With the standardization of the specification, coding against API’s you can only benefit. Your code will be cross application servers deployable. To that I admit some minor configuration per app server may be required. But no change on your code, example portable JNDI bindings.
The above reflect findings of a simple JEE7 enthusiast which looks at the technology stacks out there from the perspective of the new comer and new developer. Yes JEE7 is a mature enterprise framework to develop upon. The new features including the robust CDI, is solving many issues that the spec had in the past. The maturity that came through the community process, has evolved the framework to be more robust and simplified the configuration and programming model for the new users. I don’t understand the fanatic polemic for JEE. Our community I firmly believe have lost the battle of hype. But in real enterprise environments JEE7 is becoming the defacto choice and application servers are again coming back as the default deployment platform. On the other hand I will not take anything away from Spring. Yes is a good enterprise framework, mature and extensively used. But going forward and taking correct decisions opting for a vendor specific implementation locks you in to technologies you may don’t have the opportunity to change in the future, with the fast pace of changes in our world. I don’t neglect that the Spring community is adapting fast. But providing unified environments and ability to change, for me are far more important factors. As a person I would like this Spring against JEE fight to come to an end. Both frameworks are taking and giving to each other ideas. You can stand as a soldier behind vendors and blindly follow orders and evangelize technologies, or you can be on the fun part of people acknowledging that the most important thing is the creation of framework and tools that provide freedom. I think that the JCP process as such is a very nice place to be and involved on the specification of standards, which are lead by the community and of course backed up by major vendors.
The 100$ question for the “experts”
What is the difference of having an EJB3.1/2 with a Spring bean which is annotated as @Transactional?
(please don’t start talking about the older versions of EJB’s because I will admit that the specification back then was not mature enough..but as a JEE guy the difference is that I will admit the caveats of the framework.)