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.
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.
I guess there are various postings available, concerning this issue. For a starting point see here.
Regards,
Andreas
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.
If the client is on a separate machine, set the resourceRef property to "false".
Regards,
Andreas
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.
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
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
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
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
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