This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other Application Frameworks and the fly likes Seam Vs Spring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Seam Vs Spring" Watch "Seam Vs Spring" New topic
Author

Seam Vs Spring

Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
I have gone through many articles discussing this. Further, we had few threads, discussing same, at some other places around. But I didn't get it completely. The only thing which make me stick with spring is the industry support. Even Terracotta and Gigaspaces attempted spring integration things, regarding how to scale and stuff. Seam, IMO, is not widely accepted, although having a complete stack - lacking nowhere. Is it lacking a tipping point? How do you compare both?
Jason Porter
Ranch Hand

Joined: Apr 26, 2007
Posts: 120
This questions has been asked many, many times, even in this forum the last time Dan was here I really don't know if there's really an easy way to compare them. When you say "Spring" what part of Spring are you talking about? Is it Spring Core, MVC, Webflow, Spring-JDBC, all of Spring, etc?

To compare Seam and Spring simply for IoC isn't really a good comparison as both frameworks (taken as a whole) offer so much more. I see Seam gaining more acceptance all the time, take a look at the downloads from SourceForge for example (yeah it's not a great measure, but at least it's something).

I believe Seam will gain more and more acceptance as companies and people use JavaEE more. For example if you're using JSF, you cause yourself a lot of extra pain if you are not at least using facelets. Seam adds a lot to that set, it's pretty much Seam's sweet spot. Seam was developed originally to bring better integration with the standard EE technologies and has now expanded to bringing integration to various web technologies (Web Services [JAX-WS and JAX-RS], JSF, Wicket, GWT, JPA, etc).
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Actually, my intention is to compare the whole stack with the whole. Both actually having lots of features and integrations, providing almost everything in one pack.

Well, about JSF, I am with you. I am using Spring with Hibernate and JPA, and I am fine with. Does, Seam offer any better in this stream?

Moreover, I believe, Spring is enjoying a wider support - articles, forums, community, books, and stuff - at least at the moment. Even Axis, CXF are having Spring related HOW-TOs, in their user guides.
Jason Porter
Ranch Hand

Joined: Apr 26, 2007
Posts: 120
As far as the articles and books are concerned you'll start seeing more and more of those for Seam as time goes on. Dan has a really good listing of various Seam related blog postings and other findings at http://delicious.com/seaminaction. Sure you'll find more about Spring, but Spring also has a number of years on Seam.

Back to the Hibernate and JPA issue. How often have you run into the dreaded LazyInitializationException with Spring and Hibernate? You won't see that with Seam, you won't even see the Session-per-requst (or Open Session in View) pattern in Seam as it has something better. Your persistence (JPA or Hibernate) context will stay with you for the duration of your conversation (unit of work, not just a request) keeping all the state with it without having to do magic with the HTTP Session or hidden variables. Seam will initialize your entity manager or Hibernate Session for you and keep it around to be injected in your beans, the same way Spring will.

Web service integration really isn't anything much fancier than standard JAX-WS (with the exception of having a conversational / stateful service) in Seam (Honestly, how much integration do we need, especially with things as awesome as CXF and dynamic proxies at runtime?). Seam does have REST support with the RestEasy project in Seam 2.1. Another nice feature that just recently hit the trunk (it'll be there for 2.1.GA) is RSS integration (RSS1/2 and ATOM) with something as simple as an XHTML page similar to how you create a PDF, RTF, email, or Excel Document in Seam.

Seam also has built in support for Groovy if you like using alternative languages. You can also get Scala to work with Seam, given a little bit of work (Which actually just got easier with Seam 2.1 as you can write your own deployment and hot deployment handlers).

Another very nice feature of Seam is the ease and speed of development. Think Ruby on Rails / Grails productivity within a Java application
Dan Allen
Author
Ranch Hand

Joined: Mar 05, 2003
Posts: 164
Wow Jason, you gave an really excellent response and I don't have much to add to it.

If you are interested, I gave a rather long response to the Seam and Spring question in another thread, which I encourage you to read.


Dan Allen | http://mojavelinux.com | Author of Seam in Action - http://mojavelinux.com/seaminaction
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Thanks Jason, I am somewhat getting you. May be I need to get my hands on Seam to know, how exactly.
Jason Porter
Ranch Hand

Joined: Apr 26, 2007
Posts: 120
Check out http://www.seamframework.org/. You'll see all sorts of posts in the forms, get a feeling for what Seam can offer to a user (it's actually a Seam built web site, with code available in the download under examples/wiki), and find documentation as well as downloads there. If you're looking at playing with Seam for the first time I would recommend pulling down the latest 2.1 release which is CR1 at time of writing. It's stable enough to use and play with. The GA version for 2.1 will be out before the end of the year (hopefully before the end of November).
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Thanks again for the suggestion. In fact, I remember I downloaded the thing last year and started playing around and came up a with small tiny app. After that I got too busy in other things never had time to continue it again. But now I got enough positive responses to force me continue the thing.

Thanks to all folks.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

How often have you run into the dreaded LazyInitializationException with Spring and Hibernate?


So far, for me, never.

But I know Hibernate really well, and know to get just the data I need for each use case. Also, just to point out, in Spring Webflow 2.x you can now have a persistence context in your flow definition, so that if you did have to implement Open Session in View, now you don't. But that I believe is a recent addition, so probably not many people know this.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Jason Porter
Ranch Hand

Joined: Apr 26, 2007
Posts: 120
Originally posted by Mark Spritzler:

Also, just to point out, in Spring Webflow 2.x you can now have a persistence context in your flow definition, so that if you did have to implement Open Session in View, now you don't. But that I believe is a recent addition, so probably not many people know this.

Mark


Nice to know, thanks Mark.
Dan Allen
Author
Ranch Hand

Joined: Mar 05, 2003
Posts: 164
Mark, as you point out, the new persistence context management in Spring WebFlow is one of the crowning features in version 2.0. It puts Spring WebFlow on par with Seam in its ability to prevent the LazyInitializationException. As I might have mentioned before, there is no special sauce that Seam is applying here. The persistence context just needs to be extended beyond the request, in certain cases, and Spring WebFlow offers a suitable vehicle for doing so.

It's true that if you understand Hibernate well, and understand why a LazyInitializationException is thrown, then you also know what to do to avoid bumping into it. Unfortunately, for those that are just starting with Hibernate, or do not have the inclination to learn how Hibernate works internally, this exception starts to cut into their productivity quite dramatically (to the point where they would be better off just writing the SQL). Thus, developers appreciate having this problem solved for them, whether it be by Seam or Spring WebFlow.

Regardless, the extended persistence context is not really about avoiding this exception. It is about recognizing that this exception indicates an improper use of the persistence context. You shouldn't necessarily have to collect up all the data you need before leaving the service layer (like a Chipmunk collecting nuts before winter sets in). Rather, you should keep that persistence context available while you are actively using the entities that it manages, not only to allow crossing lazy associations, but to get the dirty checking, identity guarantees, optimistic locking, and deferred flushing. This is a topic I go into tremendous detail about in chapters 8 and 9 of Seam in Action.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Originally posted by Dan Allen:
Mark, as you point out, the new persistence context management in Spring WebFlow is one of the crowning features in version 2.0. It puts Spring WebFlow on par with Seam in its ability to prevent the LazyInitializationException. As I might have mentioned before, there is no special sauce that Seam is applying here. The persistence context just needs to be extended beyond the request, in certain cases, and Spring WebFlow offers a suitable vehicle for doing so.

It's true that if you understand Hibernate well, and understand why a LazyInitializationException is thrown, then you also know what to do to avoid bumping into it. Unfortunately, for those that are just starting with Hibernate, or do not have the inclination to learn how Hibernate works internally, this exception starts to cut into their productivity quite dramatically (to the point where they would be better off just writing the SQL). Thus, developers appreciate having this problem solved for them, whether it be by Seam or Spring WebFlow.

Regardless, the extended persistence context is not really about avoiding this exception. It is about recognizing that this exception indicates an improper use of the persistence context. You shouldn't necessarily have to collect up all the data you need before leaving the service layer (like a Chipmunk collecting nuts before winter sets in). Rather, you should keep that persistence context available while you are actively using the entities that it manages, not only to allow crossing lazy associations, but to get the dirty checking, identity guarantees, optimistic locking, and deferred flushing. This is a topic I go into tremendous detail about in chapters 8 and 9 of Seam in Action.


Yep and also the ability to spread the data gathering from the database across the request instead of all at once (what is needed) on the service call.

Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Seam Vs Spring
 
Similar Threads
How does SEAM compare with Spring ?
Is Seam Framework better framework than struts and Spring?
JBoss Seam in practical use
is Seam just another framework?
Seam AOP