Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Spring vs EJB

  1. #1
    Join Date
    Dec 2006
    Posts
    3

    Default Spring vs EJB

    Hi all,
    I am trying to understand when is better Spring instead EJB

    the documentation says:

    Spring does not support propagation of transaction contexts across remote calls, as do high-end application servers. If you need this feature, we recommend that you use EJB. However, consider carefully before using such a feature. Normally, we do not want transactions to span remote calls.

    Can somebody help me to understand it?
    If I chose spring and then I realize that I should have used EJB, How do you recommend to implement my application in order to modify this easily?

    Thanks for any comment,

  2. #2
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    When your application properly separates interfaces from implementation then there is no problem at all.

    Your client still uses the interfaces as before (just the configuration inside the application context has to be modified slightly).

    The existing serverside POJOs can be wrapped by EJBs while reusing the existing interfaces.

    The overhead of transforming a POJO based remoting application into an EJB based remoting application is quite small. So rest assured.

    Regards,
    Andreas

  3. #3
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,425

    Default

    Indeed, one of the beauties of developing an application in this way! I've not yet come across a problem where I had to go with EJB as it was the only option. I've typically found EJB to be a minor part of an application (in real terms).

  4. #4
    Join Date
    Sep 2004
    Posts
    602

    Default

    I'm assuming we are talking about session beans here.

    The question is, what does your application need to do ? If it just needs to call transactional services then Spring is hugely simpler and easier to use than EJBs.

    The main advantages are speed of development and performance, reduced code complexity and volume, ability to test code outside of a container, and being able to run your application in something as simple as Tomcat, i.e. no need for a fully blown (expensive) app server.

    The disadvantage is you can't do a remote EJB call, but in probably 99.99% of the time, why would you want to anyway ? And even if you did, do that for the 0.01% of the application that requires this, and do the rest in Spring.

  5. #5
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    Quote Originally Posted by Paul Newport View Post
    The disadvantage is you can't do a remote EJB call
    The only benefit of EJB remoting is the possibility to propagate a transactional context. Though this is a rarely used feature.

    The alternative remoting capabilities provided by spring should suffice normally.

    Regards,
    Andreas

  6. #6
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,806

    Default

    hi guys
    (sorry for my grammar)

    why until now or in these years, spring doesn't has added this feature???

    Code:
    The only benefit of EJB remoting is the possibility to propagate a transactional context.
    Though this is a rarely used feature.
    yes, rarely used, but, ..... why not finish to avoid in a 100% the EJB???

    or am i wrong in concepts???

    regards
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  7. #7
    Join Date
    Feb 2005
    Location
    Boston, MA
    Posts
    1,142

    Default

    Spring doesn't reinvent things that work fine the the way they are. If you need to propagate a transaction over a remote connection use EJBs. If you don't, there are other remoting to choose from if you want. If you don't even need remoting, then use a POJO works fine. Spring can help in any of those scenarios.
    Bill

  8. #8
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    Quote Originally Posted by wpoitras View Post
    Spring doesn't reinvent things that work fine the the way they are.
    +1

    After all, it is not the goal of Spring to replace EJBs (as far as I know ). Spring is good in encouraging good programming practice and I think, client controlled transactions don't fit this category.

    Just my 2 cents,
    Andreas

  9. #9
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,806

    Default

    After all, it is not the goal of Spring to replace EJBs (as far as I know )
    well,
    maybe no replace,
    but maybe avoid use the cumbersome world of ejb working with pojo sounds better

    it seems everybody are happy with the mentioanted feature of j2ee

    Spring doesn't reinvent things that work fine the the way they are
    i am agree, not reinvent,
    but maybe has a better solution/performance could be the objective

    regards
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  10. #10
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    It would not be particularly hard for us to add this feature. But it's not really good practice, as previous posters have explained. We are not interested in checkbox-inspired implementation of questionable features in other technologies. I cannot recall a case where I've seen propagation of tx contexts over the wire which couldn't have benefited from better design.

    If you use Spring remoting via JNDI RMI in WebLogic, at least, you should get tx propagation, as it's part of their clustered RMI not EJB.
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •