Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: How to access Spring service in Stateless bean

  1. #1
    Join Date
    Feb 2007
    Posts
    13

    Default 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. #2
    Join Date
    Aug 2004
    Posts
    2,715

    Default

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

    Regards,
    Andreas

  3. #3
    Join Date
    Feb 2007
    Posts
    13

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

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

    Default

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

    Regards,
    Andreas

  5. #5
    Join Date
    Feb 2007
    Posts
    13

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

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

    Default

    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

  7. #7
    Join Date
    Feb 2007
    Posts
    13

    Default 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

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

    Default

    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

  9. #9
    Join Date
    Feb 2007
    Posts
    13

    Default 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

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

    Default

    Quote 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

Posting Permissions

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