Feb 16th, 2007, 03:36 AM
How to access Spring service in Stateless bean
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.
Feb 16th, 2007, 04:02 AM
I guess there are various postings available, concerning this issue. For a starting point see here.
Feb 17th, 2007, 11:22 AM
Spring service in Stateless Session Bean
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.
<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>
any one do the needful . or send some sample code
Feb 19th, 2007, 12:45 AM
If the client is on a separate machine, set the resourceRef property to "false".
Feb 19th, 2007, 01:57 AM
where i place applicationContext.xml
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...
Feb 19th, 2007, 02:03 AM
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.
Feb 20th, 2007, 12:24 AM
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 .
Feb 20th, 2007, 12:31 AM
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.
Feb 20th, 2007, 01:06 AM
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)
<!-- Hibernate SessionFactory Definition -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
<!-- Spring Data Access Exception Translator Defintion -->
<bean id="jdbcExceptionTranslator" class="org.springframework.jdbc.support.SQLErrorCo deSQLExceptionTranslator">
<property name="dataSource"><ref bean="dataSource"/></property>
<!-- Hibernate Template Defintion -->
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.Hibernat eTemplate">
<!-- ========================= Start of SERVICE DEFINITIONS ========================= -->
<!-- Hibernate Transaction Manager Definition -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.Hibernat eTransactionManager">
// My Spring Service
Feb 20th, 2007, 01:34 AM
Originally Posted by bkrish_sun
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.