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

  • EJB and Spring

    Hi,

    I have few questions:
    I dont have any experience of EJB but for my new project the people is looking for struts, ejb, hibernate combination. The apllication will co-ordinate with diffrent applications.
    But I have these below questions before I start working on the things:
    1. Why we use ejb?
    2. If we used ejb for distributed application, then can we use spring for the same?
    3. Can we achieve the same things using spring whic we achieve throuth ejb?

  • #2
    Hi Malhar,

    From my understanding, you can do your app in spring w/o the EJB. I don't know how Struts fits in though.

    I would assume, that if you do not have, nor ever plan to have other EJB applications running with your app, you don't really need EJB. You would use EJB if you plan to deploy your application with other EJB applications.

    I hope this helps.

    Comment


    • #3
      You should refer to: http://static.springsource.org/sprin.../remoting.html

      Comment


      • #4
        Hi,

        I'll give you my opinion here, not a general truth because there isn't one. My personal advice is to drop both ejb and struts, and just use Spring, with Hibernate or JPA annotations. Basically, ejb 3 (do not even consider prior ejb standards) are made of 3 types of ejb:

        - Session beans: those will be substituted by Spring core functionality. The Spring application context replaces ejb deployment environment (which must be provided by an app server) and strongly simplifies everything, since your beans are just pojos and don't need to implement interfaces, have homes and proxies defined, be programmed and deployed with certain strict rules. Spring core does also much more through its DI paradigm;

        - Entity beans: Spring + Hibernate is a far better solution than using entity beans. Here, as well, you get all the benefits of ORM without all the pain of using ejbs and having to write 3 classes per bean. Hibernate's powerful hql language gives you far more control over your mappings; Hibernate integrates seamlessly with Spring, which in turn contributes with very handy transactional capabilities;

        - Message beans: here as well Spring offers seamless JMS integration, plus additional benefits like Spring Web Services. This makes message beans as useless as the other two.

        Thus, as you can see if you use Spring and Hibernate there is no added value in using ejb, and I am against using them, even if Spring also offers great facilities for ejb 3 integration.

        For what concerns Struts, it has been the first widely distributed mvc framework and as such it deserves respect. But its oldness make him suffer when compared with fresher mvc frameworks, especially with Spring 3 web mvc which is simply amazing in that you can drive the whole mvc behaviour of your application with just a few lines of xml configuration and a bunch of annotations on normal java classes. For that reason, I suggest Spring web mvc over Struts.

        This is very condensed info, if you are interested just google Spring vs ejb and you'll find dozen of articles on the subject...

        Comment


        • #5
          Hey.. Sorry for the late reply
          Thanks guys.. for the valuable information.
          Now I droped the ejb's and integrate it with spring and IBatis.
          I just want to know .. why we use ejb in distributed appllication and why not spring?
          I fouind the answer of the question and yes, we can use spring in distributed envirinment application.

          Comment


          • #6
            EJB and Spring

            EJB stands for the Enterprise Java Beans. It provides a writing transactional objects. and also we can use as a back end database connection. As I think, If you are you use a Spring then there is not need to use a EJB. Spring is also providing a best facility.

            Comment


            • #7
              My question was the same with that of Malhar but wile reading through the answers, I am really satisfied. But I still have some concerns:

              1) We just came accross Spring and we had already decided to work with GWT-EXT for our Web Tier. So what do you thingk concerning GXT + Spring + Hibernate ?

              2) What are the licencing obligations ?? The software we are building is commercial. What are the differencies between the Spring open source version and the enterprise version ? Both in terms of licencing and functionalities.

              3) It is so easy to deploy a distributed large and scalable spring application on a 7-tiers environment with 10 thousand users ???

              Comment


              • #8
                And also I forgot, what about loadbalancing ? Does Spring manage that in very large distributed environment ?

                Comment


                • #9
                  Originally posted by Malhar View Post
                  Hi,

                  I have few questions:
                  I dont have any experience of EJB but for my new project the people is looking for struts, ejb, hibernate combination. The apllication will co-ordinate with diffrent applications.
                  But I have these below questions before I start working on the things:
                  1. Why we use ejb?
                  2. If we used ejb for distributed application, then can we use spring for the same?
                  3. Can we achieve the same things using spring whic we achieve throuth ejb?
                  This short article may help you
                  http://stackoverflow.com/questions/1...d-web-services

                  Paul

                  Music & Directory
                  Last edited by Paulel; Mar 11th, 2012, 01:21 PM.

                  Comment


                  • #10
                    Nice article.
                    Really it is mostly depend on requirement and need analysis to fix the technology. Whatever EJB covers almost all things are covered by spring.
                    Till date I am happy to use Spring in my most of the applications and I am using his each and every aspect.

                    Comment


                    • #11
                      great article, i like it.

                      gar

                      Comment


                      • #12
                        Best Dentist In Pune

                        I want to know that what is Java Beans and how it works and how can i use it to improve the programming using Java beans

                        To have services of Best Dentist In Pune

                        Comment


                        • #13
                          EJB with Spring

                          I'm implementing the migration task from an ear JBoss application to Spring stand-alone jar batch (Dependency Injection). The problem is: the value of name attribute in @Stateless(name="Bean") is not localized in the Bean Factory when the annotation @EJB(name="Bean") verifies this reference in another EJB.

                          This problem is resolved when the annotations (@EJB) contains no name attribute. What is happen? The pitchfork project (http://www.springsource.com/pitchfork) also uses the annotations without the name attributes. Some idea?

                          This example shown the problem:

                          @Stateless(name = "BeanB")
                          public class BeanB implements IBeanB {

                          @EJB(name="GenericDAO")
                          private GenericDAO<Type> genericDAO;

                          ...
                          }

                          @Stateless(name = "BeanA")
                          public class BeanA implements IBeanA {

                          @EJB(name="BeanB")
                          private BeanB dao;

                          ...
                          }

                          Caused by: org.springframework.beans.factory.NoSuchBeanDefini tionException: No bean named 'BeanB' is defined
                          at org.springframework.beans.factory.support.DefaultL istableBeanFactory.getBeanDefinition(DefaultListab leBeanFactory.java:527)
                          at org.springframework.beans.factory.support.Abstract BeanFactory.getMergedLocalBeanDefinition(AbstractB eanFactory.java:1087)
                          at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:278 )
                          at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:198)
                          at org.springframework.context.annotation.CommonAnnot ationBeanPostProcessor.autowireResource(CommonAnno tationBeanPostProcessor.java:440)
                          at org.springframework.context.annotation.CommonAnnot ationBeanPostProcessor.getResource(CommonAnnotatio nBeanPostProcessor.java:414)
                          at org.springframework.context.annotation.CommonAnnot ationBeanPostProcessor$EjbRefElement.getResourceTo Inject(CommonAnnotationBeanPostProcessor.java:696)
                          at org.springframework.beans.factory.annotation.Injec tionMetadata$InjectedElement.inject(InjectionMetad ata.java:147)
                          at org.springframework.beans.factory.annotation.Injec tionMetadata.inject(InjectionMetadata.java:84)
                          at org.springframework.context.annotation.CommonAnnot ationBeanPostProcessor.postProcessPropertyValues(C ommonAnnotationBeanPostProcessor.java:302)
                          ... 29 more

                          Comment


                          • #14
                            I am looking for a way to setup a test suite for a site that is using EJB-JSF-Hibernate and was hoping to hook into the EJBs using SpringSecurity... would I be able to add spring integration easily ? I see Part III 9. testing and Part VI Integration 20. EJBs that it looks doable but was wondering how hard that would be ?

                            Can you mix Spring and JSF configurations? Usually you put your test src code in a test pkg alongside the main... would I have to run another 'spring module' configured alongside the code I want to test?

                            Hoping for some insight, any responses welcome (Thx) !

                            P.S. Are there any examples out there of doing this ?

                            Comment


                            • #15
                              fgfchfgjhgjghjkkjhk

                              Comment

                              Working...
                              X