Announcement Announcement Module
No announcement yet.
Spring and JBoss Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.


  • #2
    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.


    • #3
      Clustering and a good management console is also a place where Tomcat doesnt do as well as other big players ...


      • #4
        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)?

        Thanks again,


        • #5
          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".


          • #6
            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!


            • #7
              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 ...


              • #8
                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)?


                • #9
                  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 ...


                  • #10
                    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?


                    • #11
                      Originally posted by jeffastorey View Post
                      what I like about Spring better is that the configuration of objects via POJOs rather than annotations
                      I'm not sure I understand what you mean ... Do you mean "Configuration of Spring Bean via XML" ?

                      Actually, last time I used EJB, it was before annotations. Lots of XML ... which I dont like. I should give a try to EJB3 ...

                      I like Hibernate with annotations. And I like IoC with Spring.

                      With annotations, you can have the definition of your POJO and their related aspects (like persistence) in the same source file. I find it easier to find my way around, instead of having to switch between a java file and an XML definition.

                      I dont really have any technical reason not to like EJB. I dont have much experience with them, and when I've seen them, it usually was in huge heavy projects. Spring "feels" more lightweight, with not as much constraints on the developer. But that probably comes more from the kind of projects in which they are used than on the technology itself ...


                      • #12
                        My first experience with EJB was EJB3 so I did have the use of annotations (which is great compared to deployment descriptors). But in a development environment, it seems to slow things down sometimes since you need to recompile when you change an annotation vs changing an xml file (as you would in spring).

                        In terms of advantages/disadvantages of Spring/Hibernate persistence vs the application server's persistence layer, does the app server offer more powerful options (in addition to vendor independence)? Lastly, I think I've been hinting around this a bit, but if you use the app server's persistence layer is it then acceptable (or even expected) to have a mix of EJB (for the persistence) and Spring (for other things you may want to be lighter weight)?

                        Thanks for your help!


                        • #13
                          Antoher point for which I like Spring, is that I can run on Tomcat during the dev. That means much faster startup times than WebLogic !

                          For the compilation, I dont find it that much of a problem. Eclipse (or other IDE) should be able to handle automatic code compilation, hot code replacement (in some cases) or automatic redeployement of the application being developed.

                          Also, I'm sure there is a place for Spring even if you do use EJB. For example, you could use SpringMVC at the presentation layer.

                          On the other side, if you are comfortable with EJB and container managed persistence, there is no need to change. That's a perfectly valid solution used by tons of people as well ...

                          For a real comparison of EJB / Spring, you will need somebody else than me, with more experience in both environments ...


                          • #14
                            Thanks for all of the input. I appreciate your thoughts on the topics.