Announcement Announcement Module
Collapse
No announcement yet.
How to access Spring service in Stateless bean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to access Spring service in Stateless bean

    Hi
    my Hierarchy is view + EJB(Statless) + spring ( Service) +Hibernate.

    So can any one guide , how to access the spring service in EJB ie stateless session bean.

    View part in separate Machine
    EJB part in separate Machine.



    Regards
    Balakrishnan S.

  • #2
    I guess there are various postings available, concerning this issue. For a starting point see here.

    Regards,
    Andreas

    Comment


    • #3
      Spring service in Stateless Session Bean

      Hi

      I am running jar file in sepate machine and war in separate machine. My
      problem is i am unable get the spring servic stateless session bean. Where i put applicationcontext.xml in jar.

      applicationContext.xml
      -----------------------

      <bean id="employerContactService" class="class="org.springframework.ejb.access.Simpl eRemoteStatelessSessionProxyFactoryBean">
      <property name="jndiName" value="ejb/EmployerContactPath"/>
      <property name="resourceRef"> <value>true</value> </property>
      <property name="businessInterface" value="com.zenith.model.spring.EmployerContactServ ice"/>
      <property name="employerContactDAO"><ref local="employerContactDAO"/></property>
      </bean>


      ejb-jar.xml
      ---------
      <env-entry>
      <env-entry-name>ejb/EmployerContactPath</env-entry-name>
      <env-entry-type>java.lang.String</env-entry-type>
      <env-entry-value>/applicationContext.xml</env-entry-value>
      </env-entry>


      any one do the needful . or send some sample code


      Regards
      Balakrishnan S.

      Comment


      • #4
        If the client is on a separate machine, set the resourceRef property to "false".

        Regards,
        Andreas

        Comment


        • #5
          where i place applicationContext.xml

          Hi Andreas

          Thank you very much Andreas , my application working very fine ...
          I have one more doubt , where i place applicationContext.xml located in jar file.

          I placed the applicationContext.xml file in session entry of ejb-jar.xml.. if i have multiple session entry , so i have place the following code for each session entry. my doubt is calling of more than one session bean,so each and every time applicationContext.xml is loaded or it is loaded at the deployement ..

          please do the needful...

          <session>
          ......
          .......
          <env-entry>
          <env-entry-name>ejb/EmployerContactPath</env-entry-name>
          <env-entry-type>java.lang.String</env-entry-type>
          <env-entry-value>applicationContext.xml</env-entry-value>
          </env-entry>
          </session>






          Regrads
          Balakrishnan.

          Comment


          • #6
            You have to provide the entry for each EJB. That means that each EJB instance creates its own application context from the provided contents. To keep the overhead smaller I suggest to partition your context into multiple files so that each EJB has to load only the parts that are relevant for it.

            For sharing a context between EJB instances have a look at ContextSingletonBeanFactoryLocator and see the according section in the reference manual. As far as I recall there have also been some threads about this topic around, recently.

            Regards,
            Andreas

            Comment


            • #7
              ContextSingletonBeanFactoryLocator- Reg

              Hi
              Thank you Andreas.

              can you give me sample code URL for partition of applicationContext.xml that is used in session bean (EJB) and ContextSingletonBeanFactoryLocator concept.


              Can u guide how to use ContextSingletonBeanFactoryLocator .



              Regards
              Balakrishnan

              Comment


              • #8
                Well, partitioning just means that you have more than one Spring application context file, that is all.

                As of ContextSingletonBeanFactoryLocator I have no example at hand, but see here for how it is to be used.

                Regards,
                Andreas

                Comment


                • #9
                  EJB - Spring - Hibernate

                  I have using EJB , Spring , Hibernate in my application. In case partion of applicationContext.xml in EJB , so I have to use the following entry in all context.xml . If there is any option to declare the following entry in global file that is datasource , hibernate entry... Please help me...

                  or I have to use the following entry in all the context.xml (partion)




                  <beans>

                  <bean id="dataSource"
                  ----
                  </bean>

                  <!-- Hibernate SessionFactory Definition -->
                  <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
                  ---
                  </property>

                  <property name="dataSource">
                  <ref bean="dataSource"/>
                  </property>
                  </bean>

                  <!-- Spring Data Access Exception Translator Defintion -->
                  <bean id="jdbcExceptionTranslator" class="org.springframework.jdbc.support.SQLErrorCo deSQLExceptionTranslator">
                  <property name="dataSource"><ref bean="dataSource"/></property>
                  </bean>

                  <!-- Hibernate Template Defintion -->
                  <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.Hibernat eTemplate">
                  </bean>

                  <!-- ========================= Start of SERVICE DEFINITIONS ========================= -->

                  <!-- Hibernate Transaction Manager Definition -->
                  <bean id="transactionManager" class="org.springframework.orm.hibernate3.Hibernat eTransactionManager">
                  </bean>

                  // My Spring Service
                  </beans>


                  Regards
                  Balakrishnan

                  Comment


                  • #10
                    Originally posted by bkrish_sun View Post
                    If there is any option to declare the following entry in global file
                    Balakrishnan,

                    again, please refer to ContextSingletonBeanFactoryLocator (see the link to the reference manual I posted above). This allows to share a common context between EJB instances. This has the effect that the beans within the application context are shared, preventing you from ending up with multiple data sources and session factories.
                    Note, however, that shared beans have to be thread-safe.

                    See here for an article using EJB support in spring.

                    Regards,
                    Andreas

                    Comment


                    • #11
                      Composite_id

                      Hi
                      Thanks Andreas ,
                      My Application working very fine in this flow struts + EJB+Spring+Hibernate.


                      My doubt is howto use composite-id in hiberbate. and Please send me some sample code for composite id in Hibernate.



                      Regards
                      Balakrishnan

                      Comment


                      • #12
                        Does this help? See chapter 8.4.

                        Regards,
                        Andreas

                        Comment


                        • #13
                          compsite-id

                          Hi

                          Thanks


                          can u give me better example for composite_id in Hibernate

                          Comment


                          • #14
                            Sorry, I have no better example at hand (actually what are you missing there?).
                            Besides that I suggest opening a new thread in the "Data Access" forum as we are slightly off topic here by now. Please provide your requirements and problems there in order to allow for a specific answer.

                            Regards,
                            Andreas

                            Comment


                            • #15
                              composite-d

                              Thanks Andreas

                              actually i want know , what are the steps are made to use composite-id mapping in Hibernate.






                              regards
                              Balakrishnan S.

                              Comment

                              Working...
                              X