Announcement Announcement Module
No announcement yet.
SLSB Access from Struts Action Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • SLSB Access from Struts Action


    This is first foray into Spring so please excuse my ignorance.

    I am trying to use Spring to access local SLSBs from existing struts Actions. I have configured the applicationContext.xml as below

    <bean id="userMgr"  class="org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean" lazy-init="true">
        <property name="jndiName" value="local:ejb/ejb/UserMgr"/>
        <property name="businessInterface" value="com.prem.ejb.UserMgrLocal"/>
    <bean id="testController" class="com.prem.struts.ModuleSwitchAction">
        <property name="userMgr" ref="
    My Jndi name is as above as this is mandated by Websphere 5.3.

    In my Web.xml i have the

    In my struts action ModuleSwitchAction i have the following:
    private com.prem.ejb.UserMgrLocal userMgr;
    public void setUserMgr(UserMgrLocal userMgr) {
      this.userMgr = userMgr;
    My question:

    Will Spring set the UserMgrLocal object only when the applicationContext is first parsed (on application startup) or will it do it everytime my StrutsAction is created?

    I have added logging to the setUserMgr method and noticed that this is only being called when the application is first started.

    Is there a way to make spring invoke this setter everytime the object is constructed?

    Thanks in Advance

  • #2
    Unless you have some more configuration that you haven't shown, Spring won't inject your Struts Action with the EJB proxy at all! The Action is not a Spring-managed bean, but created by Struts itself, so Spring knows nothing about it. You have the choice of lookup up the slsb proxy from within the Action yourself (using WebApplicationContextUtils.getWebApplicationContex t().getBean()), or using the Spring-Struts integration as detailed in the user manual to have your Action dependency-injected by Spring.

    BTW, I don't think WebSphere 5.3 actually exists: I know of 5.0, 5.1, 6.0 and 6.1 (and older versions). What version are you using?



    • #3
      Hi premc,

      How you access ejb beans in netbens IDE.i have a doubt,i am creating web application and i create a EJBProject,i want to access slsb from EJBproject to web application through spring,is it possible.

      I create two applications like web and ejb is this wrong means,how to create ejb beans in netbeans IDE.

      which application support both ejb and web?

      can you tell me about your thoughts.

      Thanks and Regards,