Dec 18th, 2007, 12:28 PM
Spring and JBoss
Hi, I've been doing some research on application servers (specifically JBoss since I have used it in the past) and I'm wondering why I would want to use the overhead of a heavyweight application server, such as JBoss, when I can simply use a lightweight container like spring and use tomcat for my JSPs. It seems like (in one way or another) Spring offers the major features of an app server, such as transactions and database layers.
Is there a reason for a large scale application, such as a banking application, I would use an app server instead? Thanks.
Dec 19th, 2007, 03:55 AM
Spring offers a lot but it doesn´t replace an application server, it works very well with it. Especially if you are in the realm of distributed transactions (JTA), container managed DataSources etc. If you don't have need for all that stuff you might be satisfied by Tomcat (I used it for a few products and it works great).
Also most application servers provide an implementation of the full J2EE specifications, whereas tomcat 'only' implements the Servlet and Jsp specifications.
Dec 19th, 2007, 04:00 AM
Clustering and a good management console is also a place where Tomcat doesnt do as well as other big players ...
Dec 19th, 2007, 07:39 AM
Thanks for the responses! I have a couple of follow-up questions to that:
In terms of container managed data sources, doesn't Spring have support for that (at least for configuring a database and connecting to it via Hibernate)?
Also, is it common to use an app server such as JBoss AND Spring so you have the ability to configure your POJOs in XML, rather than using EJB3 and annotations? Or even using a combination of spring beans and EJBs (maybe using entity beans and JBoss data source management)?
Dec 19th, 2007, 08:01 AM
It is very common to use Spring and jboss. In my last project, it was Spring and WebLogic. Personally, I am not a big fan of EJB, so I tend to use Spring with Hibernate and annotations (or iBatis). But I would still use the container to manage the database connections pool.
It is of course possible to use Spring and EJB, or Spring and "almost any imaginable persistence layer".
Dec 19th, 2007, 08:37 AM
Thanks again. I only keep referencing JBoss since that's really the only app server I have used before (aside from Tomcat). In terms of using WebLogic, does WebLogic have the concept of an entity bean? If so, is it just a POJO (that can be constructed in Spring and then configured to be an entity through some WebLogic config files) or does it work some other way? Thanks!
Dec 19th, 2007, 08:42 AM
As I said, I am not a big fan of EJBs, and I'm far from an expert on the subject. But WebLogic is a full featured J2EE container, with support for EJB.
I just prefer to use Spring / Hibernate for that part ...
Dec 19th, 2007, 08:44 AM
Ah, then maybe I should rephrase. Does Spring/Hibernate have the concept of "entities" such that a POJO and it's fields can be mapped back to a database and automatically update the database (like EJB's entity beans)?
Dec 19th, 2007, 09:00 AM
Spring not directly, but that's the role of Hibernate or iBatis. And yes, Spring has support for Hibernate and iBatis. Most people probably use Spring with Hibernate ...
Dec 19th, 2007, 09:17 AM
That makes sense.
You mentioned you're not a big fan of EJBs. Could you provide some insight into why that is? I've used them before, and what I like about Spring better is that the configuration of objects via POJOs rather than annotations, but there are pros and cons to that too.
However, as briefly mentioned in previous posts, when it comes to things like distributed database transactions, failover nodes, etc. Will Spring/Hibernate be sufficient? Or would EJB and the app server's persistence layer be more appropriate here?